X-Spam-Check-By: sourceware.org Message-ID: <457CAF41.7010207@scytek.de> Date: Sun, 10 Dec 2006 20:07:13 -0500 From: Volker Quetschke User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: CTRL-c kills all children of current parent process. Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig30DACB1CEAAF8296E1D62797" X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com --------------enig30DACB1CEAAF8296E1D62797 Content-Type: multipart/mixed; boundary="------------090203030608010001090309" This is a multi-part message in MIME format. --------------090203030608010001090309 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I encountered the problem that a CTRL-c in a shell (tested with bash in rxvt and in cmd.exe with/without CYGWIN=3Dtty (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 ` 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 --=20 PGP/GPG key (ID: 0x9F8A785D) available from wwwkeys.de.pgp.net key-fingerprint 550D F17E B082 A3E9 F913 9E53 3D35 C9BA 9F8A 785D --------------090203030608010001090309 Content-Type: text/plain; name="breaktest.c" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="breaktest.c" #include #include #include #include #include void sigproc(int); void quitproc(int); int main(void) { pid_t pid1, wid; int status; char *cmnd[] =3D {"sleep", "2000", (char *)0 }; signal(SIGINT, sigproc); signal(SIGQUIT, quitproc);=20 pid1 =3D spawnvp(_P_NOWAIT, cmnd[0], (const char**) cmnd); if(pid1 =3D=3D -1) { fprintf(stderr,"%s : %s\n", cmnd[0], strerror(errno)); } fprintf(stderr, "Started child pid: %d from parent %d\n", pid1, getpid()); do { wid =3D wait(&status); fprintf(stderr, "wait returned: %d\n", wid); } while( wid !=3D pid1 ); fprintf(stderr, "pid: %d wid: %d\nDone\n", pid1, wid); } void sigproc(int a) { printf("you have pressed ctrl-c \n"); } =20 void quitproc(int a) { printf("ctrl-\\ pressed to quit\n"); exit(0); /* normal exit status */ } --------------090203030608010001090309-- --------------enig30DACB1CEAAF8296E1D62797 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (MinGW) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFfK9EPTXJup+KeF0RAmJcAKCryCFCac2EONfiFWtKfQafwxfRUACePT3d anutCAvOCwi9qGG3pDdk2Wo= =VafK -----END PGP SIGNATURE----- --------------enig30DACB1CEAAF8296E1D62797--