This is the mail archive of the cygwin mailing list for the Cygwin project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
I encountered the problem that a CTRL-c in a shell (tested with bash in rxvt and in cmd.exe with/without CYGWIN=tty (Yes, before I started the bash)) kills all children started by the running process even though it has its own signal handler in place. Take the attached source and compile it. $ gcc breaktest.c -o breaktest.exe Start it and press CTRL-c: $ ./breaktest.exe Started child pid: 372 from parent 3504 you have pressed ctrl-c wait returned: 372 pid: 372 wid: 372 Done Hmm, the CTRL-c kills the child and the parent returns because the child finished. Now start it again and send the SIGINT via `kill -INT <parentid>` from another shell (3x in this example): $ ./breaktest.exe Started child pid: 2140 from parent 3608 you have pressed ctrl-c you have pressed ctrl-c you have pressed ctrl-c That works as expected. So the question is, can killing the children of a running process by CTRL-c be considered a bug? Volker -- PGP/GPG key (ID: 0x9F8A785D) available from wwwkeys.de.pgp.net key-fingerprint 550D F17E B082 A3E9 F913 9E53 3D35 C9BA 9F8A 785D
#include <stdio.h> #include <process.h> #include <errno.h> #include <signal.h> #include <sys/wait.h> void sigproc(int); void quitproc(int); int main(void) { pid_t pid1, wid; int status; char *cmnd[] = {"sleep", "2000", (char *)0 }; signal(SIGINT, sigproc); signal(SIGQUIT, quitproc); pid1 = spawnvp(_P_NOWAIT, cmnd[0], (const char**) cmnd); if(pid1 == -1) { fprintf(stderr,"%s : %s\n", cmnd[0], strerror(errno)); } fprintf(stderr, "Started child pid: %d from parent %d\n", pid1, getpid()); do { wid = wait(&status); fprintf(stderr, "wait returned: %d\n", wid); } while( wid != pid1 ); fprintf(stderr, "pid: %d wid: %d\nDone\n", pid1, wid); } void sigproc(int a) { printf("you have pressed ctrl-c \n"); } void quitproc(int a) { printf("ctrl-\\ pressed to quit\n"); exit(0); /* normal exit status */ }
Attachment:
signature.asc
Description: OpenPGP digital signature
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |