signals

Sound synthesis with C#

若如初见. 提交于 2019-11-30 02:31:41
Is there some possibility to generate sounds in C#? I mean not just beep or open and play wave-file. I mean build the signal using different kinds of waves (sin, saw, etc.) and their options (frequencies, amplitudes, etc.) Check out NAudio on codeplex. NAudio is an open source .NET audio and MIDI library, containing dozens of useful audio related classes intended to speed development of audio related utilities in .NET. It has been in development since 2001 and has grown to include a wide variety of features. While some parts of the library are relatively new and incomplete, the more mature

Handle signals in the Java Virtual Machine

房东的猫 提交于 2019-11-30 01:43:43
问题 Is it possible to handle POSIX signals within the Java Virtual Machine? At least SIGINT and SIGKILL should be quite platform independent. 回答1: The JVM responds to signals on its own. Some will cause the JVM to shutdown gracefully, which includes running shutdown hooks. Other signals will cause the JVM to abort without running shutdown hooks. Shutdown hooks are added using Runtime.addShutdownHook(Thread). I don't think the JDK provides an official way to handle signals within your Java

Readline: Get a new prompt on SIGINT

与世无争的帅哥 提交于 2019-11-30 01:41:01
问题 I've got code similar to the following, using readline: #include <errno.h> #include <error.h> #include <getopt.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <signal.h> #include <readline/readline.h> #include <readline/history.h> void handle_signals(int signo) { if (signo == SIGINT) { printf("You pressed Ctrl+C\n"); } } int main (int argc, char **argv) { //printf("path is: %s\n", path_string); char * input; char * shell_prompt = "i-shell> "; if (signal(SIGINT, handle

What does WEXITSTATUS(status) return?

旧城冷巷雨未停 提交于 2019-11-30 00:21:10
问题 I am trying to understand how WEXITSTATUS(status) works. I have come across a piece of code where the return value of WEXITSTATUS(status) is being added to a variable. Here is the snippet: waitpid(-1, &status, 0); counter += WEXITSTATUS(status); How can the return value of WEXITSTATUS be calculated? 回答1: WEXITSTATUS(stat_val) is a macro (so in fact it does not " return " something, but "evaluates" to something). For how it works you might like to look it up in the headers (which should be

Trigger complete stack dump programmatically?

妖精的绣舞 提交于 2019-11-29 22:55:49
问题 When I send a SIGQUIT command to my java process (using kill -3 or kill -QUIT ), it prints a trace of all stacks to stderr, with information about locks held, and deadlock detection. Can I trigger this from inside the program somehow? I want to do this automatically every time a certain operation takes too long. I know it's possible to get a stack trace (see Is there a way to dump a stack trace without throwing an exception in java?, Thread dump programmatically /JDI (Java Debugger Interface)

Shell Script get CTRL+Z with Trap

社会主义新天地 提交于 2019-11-29 22:31:44
问题 I am trying to get the SIGSTOP CTRL + Z signal in my script's trap . When my script is executing, if I temporarily suspend from execution, send a SIGSTOP signal CTRL + Z , it needs to remove the files I create in it and to kill the execution. I don't understand why the following script doesn't work. But, more important, what is the correct way to do it? #!/bin/bash DIR="temp_folder" trap "rm -r $DIR; kill -SIGINT $$" SIGSTP if [ -d $DIR ] then rm -r $DIR else mkdir $DIR fi sleep 5 EDIT :

How to trigger SIGUSR1 and SIGUSR2?

隐身守侯 提交于 2019-11-29 20:45:14
I'm getting acquainted with signals in C. I can't figure out what kind of signals SIGUSR1 and SIGUSR2 are and how can I trigger them. Can anyone please explain it to me? They are user-defined signals, so they aren't triggered by any particular action. You can explicitly send them programmatically: #include <signal.h> kill(pid, SIGUSR1); where pid is the process id of the receiving process. At the receiving end, you can register a signal handler for them: #include <signal.h> void my_handler(int signum) { if (signum == SIGUSR1) { printf("Received SIGUSR1!\n"); } } signal(SIGUSR1, my_handler);

Why do many Unix programs use signals like USR1?

泪湿孤枕 提交于 2019-11-29 19:31:04
Many Unix programs accept signals like USR1 and USR2 . For example, to upgrade the executable for Nginx on the fly, you send kill -USR2 . I understand that USR1 is a "user defined" signal, meaning that whoever created the program can use it to mean "shut down" or "dump your logs" or "print foo a thousand times" or whatever. But I don't understand why they must use this arbitrary name. Why not kill -UPGRADE , or kill -GRACEFUL_SHUTDOWN ? Does Unix only allow specific signals? While we're at it, Nginx also uses the following signals (see documentation ): TERM, INT : Quick shutdown QUIT :

Trying to make close sleep on Linux

冷暖自知 提交于 2019-11-29 18:52:14
问题 I need to investigate/test the behavior of some code on Linux under conditions where close might be interrupted by signal handlers (either with or without SA_RESTART ). What is the most convenient setup to make the close syscall sleep for a measurable window of time during which I could try to hit the process with a signal? Some ideas: Intentionally slow/non-responsive NFS mount Custom FUSE driver But since these are a bit of a pain to setup, I'm wondering if there's anything more off-the

Signals and interrupts a comparison

守給你的承諾、 提交于 2019-11-29 18:41:52
Based on various references, my subjective definition of signals in Linux is "The triggers that are used to notify the processes about an occurrence of a specific event.Event here may refer to a software exception.Additionally signals may also be used for IPC mechanisms." The questions I have are I presume only exceptions (software interrupts) are notified via signals.What about the case of hardware interrupts. What are the various sources of the signal? To me it looks like kernel is always the source of a signal.(except when used for IPC) Difference between the signal handler and the ISR?.