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).
Questions tagged [signal-handling]
290 questions
1
vote
0 answers
Signal Handling for C++ for single Program
Is it possible that signal handling can be done for a particular process only.
For Ex:-
2 Independent different process A & B are running in background & signal handling for SIGTERM has been done only in the code for process A. So, if I will send…

Debugger
- 17
- 4
1
vote
0 answers
behavior of pc in armv7a assembly and in ucontext_t
If you have the armv7a assembly instruction:
400000: e59fc008 ldr r2, [pc, #4]
This loads the value at 40000c (so r2=*(pc+12) rather than r2=*(pc+4)). This is due to the pipeline which points two instructions ahead when reading. I'm…

HardcoreHenry
- 5,909
- 2
- 19
- 44
1
vote
2 answers
Ncurses: Detecting if F1 key pressed and using signals
i am trying to learn ncurses library and i came up with code below:
#include
#include
#include
static void finish(int sig);
int main(int argc, char** argv) {
char c;
initscr();
raw();
…

Olcay Ertaş
- 5,987
- 8
- 76
- 112
1
vote
1 answer
Why is snprintf not considered async safe?
I was just writing some debugging in a signal handler, and noticed that from the man7 website, snprintf is not listed as an async safe function. I would think that this would simply modify local variables, so I'm wondering why this is not async…

HardcoreHenry
- 5,909
- 2
- 19
- 44
1
vote
3 answers
Sending and handling a signal on a cloned thread
UPDATE: This appears to be a timing issue. Adding a call to sleep before the call to kill makes everything work as expected.
I have been playing with clone(2) and trying to get a handle on how it works. I am currently having trouble sending…

fido
- 5,566
- 5
- 24
- 20
1
vote
1 answer
Another signal with sigtimedwait
This code is handle SIGINT signal during 100 seconds or print timeout if SIGINT didn't arrive.
#include
#include
#include
#include
#include
#include
#include
#include…

phj47895Hbcaoo.com
- 13
- 2
1
vote
2 answers
What happens at CPU-Level if you dereference a null pointer?
Suppose I have following program:
#include
#include
#include
static void myHandler(int sig){
abort();
}
int main(void){
signal(SIGSEGV,myHandler);
char* ptr=NULL;
*ptr='a';
…

JCWasmx86
- 3,473
- 2
- 11
- 29
1
vote
1 answer
Get the register causing a segmentation fault in a signal handler
I know that:
When installing a SIGSEGV signal handler with sigaction and a sa_sigaction (rather than sa_handler), the signal handler receives a siginfo_t*, of which the si_addr is the address at which the fault occurred.
Using the ucontext_t we…
user13853391
1
vote
1 answer
Unix/Linux: Handler of SIGCONT/SIGTSTP
I'm currently writting program using signals, and I've got this trouble:
How can I change state of executing program to stopped/running without sending SIGSTOP/SIGCONT?
I understand, that I need to use:
void add_to_runqueue (struct task_struct *…

Karol
- 11
- 1
- 2
1
vote
1 answer
How can I handle SIGSTOP with SIGCONT?
what i am trying to do is that when my program receives SIGSTOP, it should send SIGCONT to itself. if i do it on terminal, it works but i want to do it in my program. I tried something like this, but it doesn't work..
can you help me?
int main()
{
…

Wokers
- 107
- 3
- 13
1
vote
1 answer
signal handler function keeps looping
My function created to handle the SIGINT signal is stuck in a constant loop. The idea is to make CTRL-C ignored by the parent process but sent to the child process (and they handle it as default). What happens is when I press CTRL-C, the signal…

zetatr
- 179
- 1
- 3
- 8
1
vote
2 answers
Installing signal handler with Python
(there is a follow up to this question here)
I am working on trying to write a Python based Init system for Linux but I'm having an issue getting signals to my Python init script. From the 'man 2 kill' page:
The only signals that can be sent to…

tMC
- 18,105
- 14
- 62
- 98
1
vote
4 answers
Is there any way to prevent a user from registering/using his own signal handler and always use a particlar handler?
My requirement is:
I have a signal handler in my tool, which is registered and used between some particular interval (i am using timer).
Now this signal handler should NOT allow any other handler to be registered after this handler…

RajSanpui
- 11,556
- 32
- 79
- 146
1
vote
4 answers
Which signals should a wrapper script pass along to a subprogram?
If I have a script that is a wrapper for another program (e.g., a daemonizer wrapper or a wrapper for mathematica), it is sometimes useful to trap signals in the wrapper program and pass them along to the subprogram.
For example, here's some Perl…

dreeves
- 26,430
- 45
- 154
- 229
1
vote
2 answers
When will Linux kernel reset the signal handler for SIGSEGV to SIG_DFL?
If I have set a signal handler for SIGSEGV, whereas a segmentation fault is generated like:
int *a = NULL;
*a = 1;
The handler will be invoked, but this signal handler will be invoked only once. So, I guess Linux kernel will reset the signal…

cong
- 1,105
- 1
- 12
- 29