This is a bit of a meta question since I think I have a solution that works for me, but it has its own downsides and upsides. I need to do a fairly common thing, catch SIGSEGV on a thread (no dedicated crash handling thread), dump some debug information and exit. The catch here is the fact that upon crash,
Tag: signals
Bash on Ubuntu on Windows: Signal handler does not work
I try to run a simple program (code below), that should receive and handle the SIGUSR1 signal. It works well on “real” Linux, but if I run it on WSL after sending SIGUSR1 it prints User defined signal 1 and terminates. AFAIK this means that SIGUSR1 wasn’t handled by program and default handler was called. How can I make signal
Interruption of signal handler with other signal?
Can a signal handler be interrupted by another signal (except of SIGKILL, SIGSTOP)? Therefore, do I need to check for EINTR in my signal handler when calling interruptable syscalls? (Linux and other Unixes) Answer Yes, the execution of a signal handler may itself be interrupted by the delivery of another signal. There are a few nuances, however. By default, user-defined
Wait for signal, then continue execution
I am trying to make a program that suspends its execution until a signal arrives. Then, after the signal arrives I just want my code to continue its execution from where it was. I don’t want it to execute a function handler or whatsoever. Is there a simple way of doing this? I have been struggling for a week or
A script wrapper that turns SIGINT into SIGHUP
I use Leiningen REPL that uses SIGINT to interrupt currently running code and to output a new prompt. The REPL can be stopped using SIGHUP or SIGKILL. I don’t actually run anything in the REPL – I just use it for some pre-defined side-effects. The problem is that IntelliJ IDEA can only send SIGINT when it exits to the processes
Signal Handling C programming on ubuntu
While I sending kill -9 command to a program on ubuntu , I want to close other running processes before the program closes.I am trying this with c programming . Could it be something like this? How can I say program if you get KILL command you should do something? Answer Per the POSIX standard <signal.h> documentation: … The following
pthread_kill() not sending signal to main thread (main program)
signal can be received in any threads or main program itself. i have created one auxiliary thread from main program. so there is two thread in my program 1. main thread (process itself) 2. Auxiliary Thread. I just want that whenever signal arrived in my auxiliary thread, that should send signal to my main thread (program). i am using pthread_kill(main_threadid,
Using a signal handler to process datas received from a fifo
I am writing a simple client/server communication with fifo but i am stuck at using a signal handler to process client request. The server open a fifo in readonly and non blocking mode, read datas received and writes back some datas to the client fifo. And this actually works fine when there is no signal handler on the server side.
Linux server C code stalls after receiving a signal
I have a problem with this simple server code, it works as expected until it receives a signal. For debug I print server and client file descriptors before calling select with the line: When running normally it keeps printing but when it receives a signal it prints this line once and then the program stalls. Using GDB I put a
How to make parent process invoke wait when child exits with parent unblocked in Linux?
Here is an example, waitpid system call will block parent process until child process exits: What I want to achieve is parent process won’t be blocked, this can be done by using signal, so I changed my code: But another problem comes, if child exit before signal(SIGCHLD, handler), child will be a zombie, we can’t expect the child exit after