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
15
votes
1 answer

Can std::atomic_flag be used in a signal handler

According to the C++17 standard, [support.signal], the atomic object should satisfy the following requirements to be used in a signal handler: [...], or f is a non-static member function invoked on an object A, such that A.is_­lock_­free() yields…
11
votes
4 answers

Python:Django: Signal handler and main thread

I am building a django application which depends on a python module where a SIGINT signal handler has been implemented. Assuming I cannot change the module I am dependent from, how can I workaround the "signal only works in main thread" error I get…
codeJack
  • 2,423
  • 5
  • 24
  • 31
11
votes
1 answer

Signal handling in python-daemon

I installed python-daemon and now I'm trying to get the signal handling right. My code: #!/usr/bin/env python # -*- coding: utf-8 -*- import signal, time, syslog import daemon def runDaemon(): context = daemon.DaemonContext() …
Ocaso Protal
  • 19,362
  • 8
  • 76
  • 83
10
votes
2 answers

longjmp and RAII

So I have a library (not written by me) which unfortunately uses abort() to deal with certain errors. At the application level, these errors are recoverable so I would like to handle them instead of the user seeing a crash. So I end up writing code…
Evan Teran
  • 87,561
  • 32
  • 179
  • 238
9
votes
4 answers

Reading shared data inside a signal handler

I am in a situation where I need to read a binary search tree (BST) inside a signal handler (SIGSEGV signal handler, which according to my knowledge is per thread base). The BST can be modified by the other threads in the application. Now since a…
MetallicPriest
  • 29,191
  • 52
  • 200
  • 356
9
votes
2 answers

Signal handling in OpenMP parallel program

I have a program which uses POSIX timer (timer_create()). Essentially the program sets a timer and starts performing some lengthy (potentially infinite) computation. When the timer expires and a signal handler is called, the handler prints the best…
user7610
  • 25,267
  • 15
  • 124
  • 150
9
votes
2 answers

Signal handling with qemu-user

On my machine I have an aarch64 binary, that is statically compiled. I run it using qemu-aarch64-static with the -g 6566 flag. In another terminal I start up gdb-multiarch and connect as target remote localhost:6566. I expect the binary to raise a…
user277465
9
votes
1 answer

signal handling pika / python

I am using pika.BlockingConnection in a consumer which performs some tasks for each message. I have also added signal handling so that the consumer dies properly after completely performing all tasks. While message is being processed and signal is…
user3295878
  • 831
  • 1
  • 6
  • 19
9
votes
1 answer

Trap all accesses to an address range (Linux)

Background I'm writing a framework to enable co-simulation of RTL running in a simulator and un-modified host software. The host software is written to control actual hardware and typically works in one of two ways: Read/Write calls through a…
Chiggs
  • 2,824
  • 21
  • 31
9
votes
2 answers

Is it possible to handle a SEGFAULT orginating in native code?

I have a Java 1.6 application that accesses a third party native module, through a JNI class provided as the interface. Recently we noticed that a SEGFAULT is occurring in the native module, and is causing our application to crash. Is it possible…
C. Ross
  • 31,137
  • 42
  • 147
  • 238
8
votes
4 answers

What's the difference between various $SIG{CHLD} values?

What is the difference between these settings? $SIG{CHLD} = 'IGNORE' $SIG{CHLD} = 'DEFAULT' $SIG{CHLD} = '' $SIG{CHLD} = undef According to "Advanced Programming in the UNIX Environment, 2nd edition", figure 10.1 the default value of SIGCHLD…
Trueblood
  • 515
  • 2
  • 5
  • 11
8
votes
1 answer

Waking up thread from signal handler

I understand that about the only thing, a signal handler in ISO/C++11 is allowed to do is to read from or write to a lock free atomic variable or a volatile sig_atomic_t (I believe, POSIX is a little bit more permissive and allows to call a bunch of…
MikeMB
  • 20,029
  • 9
  • 57
  • 102
7
votes
1 answer

How to deal with errno and signal handler in Linux?

When we write a signal handler that may change the errno, should we save errno at the beginning of the signal handler and restore the errno at the end of it? Just like below: void signal_handler(int signo){ int temp_errno = errno; ***…
cong
  • 1,105
  • 1
  • 12
  • 29
7
votes
2 answers

Reap children without setting $SIG{CHLD} to IGNORE or to a custom signal handler

I am trying to write a socket server that forks for every connection. I have been successful except for one small caveat: my child processes use Net:OpenSSH->capture2() which requires that $SIG{CHLD} not be set to IGNORE or to a custom signal…
Michael
  • 83
  • 1
  • 4
6
votes
2 answers

Signal handler accessing queue data structure (race condition?)

I'm currently writing a small shell in C++. Jobs and the PIDs associated with them are stored within a queue of job pointers (job *). When a new job is run, information about it is added to the queue. Since multiple jobs can be handled…
BSchlinker
  • 3,401
  • 11
  • 51
  • 82
1
2
3
19 20