signal handler is not called in DEBUG [message #1714149] |
Tue, 10 November 2015 09:56 |
chen zero Messages: 9 Registered: July 2009 |
Junior Member |
|
|
Hello,
Eclipse version:
Luna Service Release 2 (4.4.2)
Build id: 20150219-0600
I found that if I use "kill -2 pid"
to send signal to the app under debug, the signal handler will not called.
If I ran the app in Terminal, the handler will be called.
if there is any constraints to debug app that handles signals?
but how to debug if app uses signals ?
Thanks!
chenzero
#include <cstdio>
#include <signal.h>
#include <unistd.h>
static bool loop;
static void sigfunc(int);
static void sigfunc(int signo) {
printf("SIGINT received!\n");
loop = false;
}
int main(int argc, char** argv) {
loop = true;
if (signal(SIGINT, sigfunc) == SIG_ERR) {
printf("Could not setup signal handler for SIGINT!\n");
return -1;
}
pid_t pid = getpid();
printf("Waiting for SIGINT, pid: %d Press Ctrl+C to exit.\n", pid );
printf("kill -2 %d \n", pid);
while (loop) {
;
}
return 0;
}
[Updated on: Wed, 11 November 2015 05:36] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03395 seconds