This is the mail archive of the cygwin@sourceware.cygnus.com 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]

[BUG] spawnlp(_P_WAIT, ...) confused if spawned processes execs


The test case below illustrates a problem with spawnlp.  The correct
sequence of output should be something like:

first
second
exited

It is instead:

first
exited
second

Looking at the sources, it appears that the problem is that the spawn
functions only wait for the Windows process that *they* created.  If I
read the way 'exec' works correctly, it essentially creates a new Windows
process, performs some cygnus magic on it, and "jumps to it", terminating
the "parent" process.  This erroneously signals the spawn function that
its child has exited.  Well, its Windows child has, really, but its
Unix child hasn't.

I once again, think that this would be difficult to fix, but maybe Sergey
will prove me wrong.  I love to be proven wrong when the result is better
software!

#include <process.h>
main()
{
spawnlp(_P_WAIT, "sh", "sh", "-c",
	"echo first; exec sh -c \"sleep 2; echo second\"", 0);
printf("exited\n", ret);
exit(0);
}
-- 
http://www.bbc.com/	cgf@bbc.com			"Strange how unreal
VMS=>UNIX Solutions	Boston Business Computing	 the real can be."
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]