Questions tagged [signal-handling]

In the C Standard Library, signal processing defines how a program handles various signals while it executes. A signal can report some exceptional behavior within the program (such as division by zero), or a signal can report some asynchronous event outside the program (such as someone striking an interactive attention key on a keyboard).

290 questions
3
votes
2 answers

backtrace_symbols fails to print the very function that has caused the signal

I'm implementing a simple crash logger for my C++ application: static void handler(int, siginfo_t * info, void *) { void *array[1000]; switch (info->si_signo) { case SIGILL: Logger() << "Received SIGILL"; break; case…
Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335
3
votes
1 answer

Strange output when using fork() and signal handling

#include #include #include #include #include void sighup() { signal(SIGHUP,sighup); printf("Received SIGHUP! Happy Now ??\n"); } void sigbus() { signal(SIGBUS,sigbus); …
ac-lap
  • 1,623
  • 2
  • 15
  • 27
3
votes
0 answers

Handling Signal Sent by "Stop" While Running Debugger in QT Creator

While running my program normally in QT Creator (on a Linux machine), when I hit the "stop" button, I am able to handle the SIGTERM signal and gracefully shut down my software. However, when I run in debug mode and hit the same button, no signal…
user985030
  • 1,557
  • 1
  • 16
  • 32
3
votes
1 answer

child-process signal handling in c

I need your help in an exercise i have about signal handling between processes. I think that it's a trivial question but i can't find the answer anywhere. I want to print something from the parent in a file, send a signal from the parent to the…
Mario
  • 767
  • 1
  • 14
  • 42
3
votes
1 answer

Checking for installed signal handler

I have a library which installs a signal handler for SIGSEGV for debugging purpose. The SIGSEGV handler just prints some information and then exits the program. Recently, I had the need to invoke this library from Java (using JNI), and the problem I…
Saurabh
  • 1,059
  • 10
  • 20
3
votes
3 answers

Application receiving mysterious SIGINTs

We have a small daemon application written in C for a couple of various UNIX platforms (this problem is happening in SunOS 5.10), that basically just opens up a serial port and then listens for information to come in via said port. In this…
Morinar
  • 3,460
  • 8
  • 40
  • 58
2
votes
2 answers

Restoring original signal in sigaction

I have sigaction defined and it works fine. However I want to restore the original signal after my action is completed. This is my sigaction: static void signal_handler(int signal, siginfo_t *info, void *reserved) { //Some logging statements …
OceanBlue
  • 9,142
  • 21
  • 62
  • 84
2
votes
0 answers

Boost signal handler - calling default handler

I'm using boost signal handler in order to properly teardown my process when a signal arrives (SIGTERM, SIGSEGV and SIGABRT). However, after the teardown the process, I'd like to continue the default system flow of signal handling (that terminates…
Zohar81
  • 4,554
  • 5
  • 29
  • 82
2
votes
1 answer

Is it possible to terminate only the one thread on receiving a SIGSEGV?

I have an application which starts multiple threads. I am using a signal handler to catch the signals. I don't want my application to quit on SIGSEGV; I want to terminate only the thread that incurred the signal, and to continue the flow of the…
Vivek Goel
  • 22,942
  • 29
  • 114
  • 186
2
votes
0 answers

Why does defining signal handlers inside python class methods no longer work from ipython?

I have a large class of data acquisition methods and settings, which we usually work with from an ipython terminal. The class also defines a signal handler method, cleanup, which is supposed to gather any pending incoming data streams and close…
schlepuetz
  • 21
  • 3
2
votes
1 answer

Jupyter reverts signal handler to default when running next cell

My custom defined signal handler gets reverted in jupyter when I run the very next cell. This doesn't appear to be the case when running python and ipython.
agent nate
  • 332
  • 4
  • 17
2
votes
0 answers

Signal Handler for Flask application with Gunicorn + Eventlet

Currently, I am trying to add a signal handler that correctly updates the database state whenever our server is re-started/updated by listening for SIGTERM interrupts. Our Flask app is on a Gunicorn server monkey-patched with eventlet. However,…
John Targaryen
  • 1,109
  • 1
  • 13
  • 29
2
votes
1 answer

sigaction is catching signal only once

Consider the following code: #include #include void catch () { printf("hi\n"); } int main() { struct sigaction act; act.sa_handler = catch; sigaction(SIGINT, &act, NULL); …
asha rani
  • 41
  • 6
2
votes
1 answer

Matlab: Is it possible to create signal handlers (.m scripts)

I've looked through the documentation, etc, but I'm not seeing anything obvious. I'd like to have a signal handler that can intercept ^C, ^\, or some other keypress that could be used to interrupt a long-running script (each discrete computation is…
Brian Vandenberg
  • 4,011
  • 2
  • 37
  • 53
2
votes
2 answers

Program won't end after catching SIGINT before pressing ENTER?

Why does my program not end until I press ENTER in terminal after pressing Ctrl+C? Here is my code: static volatile sig_atomic_t keepRunning = 1; void intHandler(int sig) { keepRunning = 0; } int main(int argc, char *argv[]) { …
cheshire
  • 1,109
  • 3
  • 15
  • 37