spawn doesn't return for non-cygwin programs (and also is unbreakable)

Volker Quetschke
Tue Dec 26 00:48:00 GMT 2006


I recently tripped over the following problem: If a non-cygwin
program gets started by cygwin's spawnvp() the spawn doesn't return
until the started program returns.

To illustrate the problem just compile attached the attached
breaktestwin.c file as a cygwin executable

$ gcc breaktestwin.c -o breaktestwin.exe

and the attached wsleep.c as a native W32 executable

$ gcc -mno-cygwin wsleep.c -o wsleep.exe

and start breaktestwin.exe.

$ ./breaktestwin.exe

You will see that the "Started child  ..." message will not
appear until wsleep finishes.

This problem is actually known since 2001 but I thought it's
OK to mention it again. See:

Another point that did not get mentioned AFAIK is that the
program is not interruptible by CTRL-c while spawnvp() is
waiting for it's "child". (Only true if CYGWIN=tty or when
rxvt or something that handles tty's correctly is used.)

Try hitting CTRL-c while breaktestwin.exe is running from
a tty enable shell. The SIGINT will be handled after the
spawnvp() finishes.



PGP/GPG key  (ID: 0x9F8A785D)  available  from
key-fingerprint 550D F17E B082 A3E9 F913  9E53 3D35 C9BA 9F8A 785D
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: breaktestwin.c
URL: <>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: wsleep.c
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 248 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the Cygwin mailing list