Can I distinguish between a signal that is delivered directly to the process and delivered through the debugger.
Case 1:
$ ./process1
process1 (not ptraced)
//set up handler
alarm(5);
....
//signal is handled and I can parse handler parameters
Case 2:
$ debugger1 ./process1
process1 (is ptraced by debugger1)
//set up handler
alarm(5);
...
//signal is catched by debugger1. It resumes process1 with PTRACE_CONT,
// signal_number is 4th parameter of PTRACE_CONT.
//signal is redelivered to process1
//and then is handled.
So, how can I detect in the signal handler whether it was re-sent by the debugger or sent by the system?
Linux OS, kernel 2.6.30. Programs are written in regular C. In a real program, SIGALRM is used, but it is generated not with alarm(), but with setitimer().
source
share