Using clone() to fork a process you can specify the signal a child process should send its parent on death instead the “normal” SIGCHLD. Is it possible to change the set termination signal after the child was created? Either by the child or the parent? Answer I (quickly) scanned Linux’ source for assignments to struct task_struct’s member exit_signal. This seems
Tag: signals
Linux: effect of signal on multiple threads
I don’t think this is a duplicate. I have a very specific question about what happens to other threads when a signal handler is invoked. I have a multithreaded program that plays with hardware. On getting SIGTERM (from a parent process), I want the signal handler to set the state of the hardware to a given state, and exit(1). I
Signals in ppoll not handled immediately
I wrote a small ppoll test but I am confused about the signal handling. The man page says: The relationship between poll() and ppoll() is analogous to the relationship between select(2) and pselect(2): like pselect(2), ppoll() allows an application to safely wait until either a file descriptor becomes ready or until a signal is caught. In my case fd changes
Checking if errno != EINTR: what does it mean?
I’ve found this piece of code used several times (also a similar one where it’s used open() instead of write()). Why it is checked if && errno != EINTR here ? Looking for errno on man I found the following text about EINTR, but even if I visited man 7 signal that doesn’t enlighten me. EINTR Interrupted function call (POSIX.1);
C: Stop executing and jump to specific point in program on receiving a signal
I have written a code where two independent programs (say 1 & 2) are communicating via message queues. Each programs sends a message of a specific mtype and waits for response of specific mtype. Based on the mtype functions are invoked. program 2 initially waits on select() on the message queue waiting for message chain initiation from program 1 and
Linux Shutdown and Java Shutdown Hook
When I run a Java process in background and I shut down the computer (ArchLinux), will the computer wait some seconds for the termination of my shutdown-hook in Java? Answer A shutdown hook will be called when a call to close the JVM is made. However, there is no guarantee that the hook will be called. The hook might not/won’t
What happens after the execution of a handler function on the SIGCHLD signal in C?
I was wondering what exactly happens after the execution of a handler on a signal in C, more specifically on the SIGCHLD signal. I’m actually building a shell and I need to do this: User enters a command with “&” as the last argument A new process is created with fork The parent process returns to the main function and
Why signal handler for SIGSEGV doesn’t catch my C++ throw exception?
I was trying to see if SIGSEGV signal hander could help to deal with unhandled exception of C++, I experiment it: $ g++ -g h.cpp -rdynamic && ./a.out terminate called after throwing an instance of ‘int’ Aborted (Core dump) Well, the program doesn’t print crash call stack back trace as I expected. My question is: As long as it terminates,
how to alternate continously Signal handler
I want to write a program in c for linux that catchs the first SIGUSR1 signal, ignores the second one and continue in this behaviour (catch-ignore) for the successive SIGUSR1 signals. I wonder how to keep alternating between the two handlers, because once i set the handler to SIG_IGN, the signal will be ignored and I won’t be able to
Catching SIGSEGV when triggered by corrupt stack
I’ve been working on some buggy code and wanted to install a SIGSEGV handler to get more information about the crash. However, I noticed that my handler is not invoked. I’ve been looking for a reason and it seems it has to do with a corrupt stack pointer value (it’s not getting masked for sure). Here’s some proof-of-concept code I