signals

cancel join after sys.exit in multiprocessing

冷暖自知 提交于 2019-12-23 19:13:39
问题 On OSX I create a tree of processes with multiprocessing.Process. When I send a signal to a parent process, the process enters a join state: [INFO/MainProcess] process shutting down [INFO/MainProcess] calling join() for process Process-1 I am already catching the signal with a signal handler and then calling sys.exit(1). Is there something I can call before sys.exit(1) that will prevent this process from waiting for its child? 回答1: You can avoid this by setting the daemon property to True on

sigwait in Linux (Fedora 13) vs OS X

时光怂恿深爱的人放手 提交于 2019-12-23 18:58:22
问题 So I'm trying to create a signal handler using pthreads which works on both OS X and Linux. The code below works on OS X but doesn't work on Fedora 13. The application is fairly simple. It spawns a pthread, registers SIGHUP and waits for a signal. After spawning the signal handler I block SIGHUP in the main thread so the signal should only be sent to the signal_handler thread. On OS X this works fine, if I compile, run and send SIGHUP to the process it prints "Got SIGHUP". On Linux it just

How do I guarantee cleanup code runs in Windows C++ (SIGINT, bad alloc, and closed window)

空扰寡人 提交于 2019-12-23 18:57:33
问题 I have a Windows C++ console program, and if I don't call ReleaseDriver() at the end of my program, some pieces of hardware enter a bad state and can't be used again without rebooting. I'd like to make sure ReleaseDriver() gets runs even if the program exits abnormally, for example if I hit Ctrl+C or close the console window. I can use signal() to create a signal handler for SIGINT . This works fine, although as the program ends it pops up an annoying error "An unhandled Win32 exception

Child process ignores SIGQUIT if started from Java

给你一囗甜甜゛ 提交于 2019-12-23 18:48:41
问题 Take this simple example: public class Main { public static void main(String[] args) throws Exception { Runtime.getRuntime().exec("sleep 1000"); // This is just so that the JVM does not exit Thread.sleep(1000 * 1000); } } I am running this on Linux using openjdk6. If I try to send a SIGQUIT signal to the "sleep" process, it ignores it. Other signals ( SIGINT , SIGTERM etc) all work fine, but SIGQUIT is ignored. If I just run sleep 1000 from a shell without using Java, then SIGQUIT is handled

Preventing SIGPIPE

余生颓废 提交于 2019-12-23 16:23:26
问题 Let's consider the following example. I have a parent process that creates a pipe, spawns a child and read the child's standard output using this pipe. At some point, the parent process is no longer interested in the child's output, and closes the read end of the pipe. Apparently, if the child keeps writing, will this result in the child process receiving a SIGPIPE signal. Question: is there a way to redirect the child's output to /dev/null so that it still keeps running and producing output,

Signal handling in Python

寵の児 提交于 2019-12-23 14:23:40
问题 In my program I have a bunch of threads running and I'm trying to interrupt the main thread to get it to do something asynchronously. So I set up a handler and send the main process a SIGUSR1 - see the code below: def SigUSR1Handler(signum, frame): self._logger.debug('Received SIGUSR1') return signal.signal(signal.SIGUSR1, SigUSR1Handler) [signal.signal(signal.SIGUSR1, signal.SIG_IGN)] In the above case, all the threads and the main process stops - from a 'c' point of view this was unexpected

Where to declare sig_t signal for SIGPIPE

跟風遠走 提交于 2019-12-23 13:07:27
问题 I'm currently using a kqueue to handle multiple Clients per Thread in a Serverprocess so I don't want the thread to be terminated when the Signal SIGPIPE appears, i would just like to remove the according socked id from the kqueue. So My question is: Is there a way to get the according socketid inside a Signalhandle and parse it back to the Process to remove it from the event kqueue or would i have jsut to SIG_IGN the SIGPIPE and handle the remove by returning of -1 from send? and would it

Elm - Check the Type of a value

a 夏天 提交于 2019-12-23 12:35:40
问题 Does a function exists that checks the Type of a variable in an Elm? For example (repl): numberTwo = 2 ..... returnType numberTwo "number" : String The motivation for this is that when you are using Signal.map[n] the situation usually arises that not all of the arguments to the function to be applied are Signals - they then usually have to be 'promoted' to Signals using Signal.constant - if I could check the type of such arguments, I could create a function Signal.allSigMap[n] that would turn

Find PID of a Process by Name without Using popen() or system()

会有一股神秘感。 提交于 2019-12-23 10:17:12
问题 I've a process name and I've to send a kill() signal to that process but I need its PID to call kill() . I would only like to use: popen("pidof process_name"); as the last thing. Is there any other way to find out the process' PID? One way I could think of is to send a socket request to that process and ask to its PID. The other way is a little too complicated for a simple code I'm writing: to do what pidof command's source code is actually doing (it uses a function call find_pid_by_name()

What keyboard signal apart from Ctrl-C can I catch?

寵の児 提交于 2019-12-23 09:33:59
问题 I have a (C, Linux) application which handles Ctrl-C SIGINT by shutting down. I'd like to add another signal handler so that I can use another keystroke combo for "reload configuration while running". So I'm looking from a signal I can send to the foreground process by keystroke, which doesn't force the process to quit or suspend. Are there any others? 回答1: You can use ctrl+Z , SIGTSTP Value = 20 For more details refer this link. 回答2: You can try Ctrl - \ which is SIGQUIT if you absolutely