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
160
votes
7 answers

Where should signal handlers live in a django project?

I have just started implementing signal listeners in a django project. While I understand what they are and how to use them. I am having a hard time figuring out where I should put them. The documentation from the django site has this to…
Jason Webb
  • 7,938
  • 9
  • 40
  • 49
145
votes
5 answers

What is the difference between SIGSTOP and SIGTSTP?

Just wondering about the difference between SIGSTOP and SIGTSTP signals.
user1419715
  • 1,607
  • 2
  • 12
  • 8
81
votes
6 answers

How to write a signal handler to catch SIGSEGV?

I want to write a signal handler to catch SIGSEGV. I protect a block of memory for read or write using char *buffer; char *p; char a; int pagesize = 4096; mprotect(buffer,pagesize,PROT_NONE) This protects pagesize bytes of memory starting at…
Adi
  • 1,589
  • 3
  • 19
  • 27
79
votes
8 answers

Providing/passing argument to signal handler

Can I provide/pass any arguments to signal handler? /* Signal handling */ struct sigaction act; act.sa_handler = signal_handler; /* some more settings */ Now, handler looks like this: void signal_handler(int signo) { /* some code */ } If I…
hari
  • 9,439
  • 27
  • 76
  • 110
67
votes
2 answers

How are asynchronous signal handlers executed on Linux?

I would like to know exactly how the execution of asynchronous signal handlers works on Linux. First, I am unclear as to which thread executes the signal handler. Second, I would like to know the steps that are followed to make the thread execute…
Daniel Trebbien
  • 38,421
  • 18
  • 121
  • 193
48
votes
5 answers

Which signal does ctrl-x send when used in a terminal?

On Linux/Unix there are signals. The CtrlC one (SIGINT) is obvious to me. Now, in some other applications there are signals via CtrlX?! Is that even a signal or does it generate an escape sequence? Is there anything else I can use as something…
imacake
  • 1,703
  • 7
  • 18
  • 26
45
votes
7 answers

Segmentation fault handling

I have an application which I use to catch any segmentation fault or ctrl-c. Using the below code, I am able to catch the segmentation fault but the handler is being called again and again. How can I stop them. For your information, I don't want…
user1225606
  • 1,123
  • 2
  • 14
  • 14
37
votes
6 answers

Is it possible to use signal inside a C++ class?

I am doing something like this: #include class myClass { public: void myFunction () { signal(SIGIO,myHandler); } void myHandler (int signum) { /** * Handling code */ } } I am…
Pablo Herrero
  • 1,724
  • 5
  • 18
  • 23
35
votes
8 answers

Python - Trap all signals

In python 2.6 under Linux, I can use the following to handle a TERM signal: import signal def handleSigTERM(): shutdown() signal.signal(signal.SIGTERM, handleSigTERM) Is there any way to setup a handler for all signals received by the…
Justin Ethier
  • 131,333
  • 52
  • 229
  • 284
21
votes
2 answers

python: windows equivalent of SIGALRM

I have this decorator: def timed_out(timeout): def decorate(f): if not hasattr(signal, "SIGALRM"): return f def handler(signum, frame): raise TimedOutExc() @functools.wraps(f) def…
Claudiu
  • 224,032
  • 165
  • 485
  • 680
20
votes
2 answers

Java signal chaining

I've got a program with a specialized Process-type class which handles executing the processes natively on Linux. It does not use Java's Process class at all, because it needs to do some special handling of the process. Because of this, it also…
rm5248
  • 2,590
  • 3
  • 17
  • 16
17
votes
3 answers

signal handler function in multithreaded environment

In my multithreaded GUI application I have the following signal handling code. I want to improve this code so that it will be correct and threading safe but there are some things I don't fully understand in signal handling: is signal handled at the…
tommyk
  • 3,187
  • 7
  • 39
  • 61
16
votes
1 answer

How do i remove a signal handler

I've made the follow signal handler struct sigaction pipeIn; pipeIn.sa_handler = updateServer; sigemptyset(&pipeIn.sa_mask); sa.sa_flags = SA_RESTART; if(sigaction(SIGUSR1, &pipeIn, NULL) == -1){ printf("We have a problem, sigaction is not…
Dr.Knowitall
  • 10,080
  • 23
  • 82
  • 133
16
votes
1 answer

compile errors using signal.h in Linux

I'm writing a shell program that must handle signals. My relevant signal handling related code is as follows: #include ... #include ... void installSigactions( int, struct sigaction* ); void handler_function( int signal_id…
rurouniwallace
  • 2,027
  • 6
  • 25
  • 47
15
votes
2 answers

What constitutes asynchronous-safeness

It is said that you should only call asynchronous-safe functions inside a signal handler. My question is, what constitutes asynchronous-safeness? A function which is both reentrant and thread safe is asynchronous-safe I guess? Or No?
MetallicPriest
  • 29,191
  • 52
  • 200
  • 356
1
2 3
19 20