summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/spawn.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2000-03-15 04:49:36 +0000
committerChristopher Faylor <me@cgf.cx>2000-03-15 04:49:36 +0000
commit332600d80cdfcf46ce36c9f5c77b452d8636fa7f (patch)
tree31ba7287033df0ea28d03a345d08840662a1b798 /winsup/cygwin/spawn.cc
parent31b3dbe174d47b96ee7a8b08c7e67b50505eb79e (diff)
downloadcygnal-332600d80cdfcf46ce36c9f5c77b452d8636fa7f.tar.gz
cygnal-332600d80cdfcf46ce36c9f5c77b452d8636fa7f.tar.bz2
cygnal-332600d80cdfcf46ce36c9f5c77b452d8636fa7f.zip
Pipe changes throughout suggested by Eric Fifer <EFifer@sanwaint.com>
* debug.cc (threadname_init): Pass name of lock as arg 2 of new_muto. * malloc.cc (malloc_init): Ditto. * sigproc.cc (sigproc_init): Ditto. * exceptions.cc (events_init): Ditto. (call_handler): Eliminate special case for hExeced. Report locked thread in debugging output. * fhandler.cc (fhandker_pipe::fhandler_pipe): Propagate device type to base class. * fhandler.h (fhandler_pipe): Ditto. * hinfo.cc (hinfo::build_fhandler): Pass specific type of pipe to constructor. * spawn.cc (spawn_guts): Eliminate dependency on signal when waiting for subprocess. * strace.cc: Remove obsolete #ifdef. * sync.cc (muto::muto): Save the name of the muto. (muto:~muto): Also release the muto. * sync.h: Add a muto name field. * select.cc (peek_pipe): Avoid doing a PeekNamedPipe on the write end of a pipe.
Diffstat (limited to 'winsup/cygwin/spawn.cc')
-rw-r--r--winsup/cygwin/spawn.cc105
1 files changed, 52 insertions, 53 deletions
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 59b1e81c5..e4f41b26c 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -635,8 +635,8 @@ skip_arg_parsing:
{
BOOL exited;
- HANDLE waitbuf[3] = {pi.hProcess, signal_arrived, spr};
- int nwait = 3;
+ HANDLE waitbuf[2] = {pi.hProcess, spr};
+ int nwait = 2;
SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_HIGHEST);
res = 0;
@@ -644,61 +644,60 @@ skip_arg_parsing:
exec_exit = 1;
exited = FALSE;
MALLOC_CHECK;
- waitfor:
- switch (WaitForMultipleObjects (nwait, waitbuf, FALSE, timeout))
+ for (int i = 0; i < 100; i++)
{
- case WAIT_TIMEOUT:
- syscall_printf ("WFMO timed out after signal");
- if (WaitForSingleObject (pi.hProcess, 0) != WAIT_OBJECT_0)
+ switch (WaitForMultipleObjects (nwait, waitbuf, FALSE, timeout))
{
- sigproc_printf ("subprocess still alive after signal");
- res = exec_exit;
- }
- else
- {
- sigproc_printf ("subprocess exited after signal");
- case WAIT_OBJECT_0:
- sigproc_printf ("subprocess exited");
- if (!GetExitCodeProcess (pi.hProcess, &res))
- res = exec_exit;
- exited = TRUE;
- }
- if (nwait > 2)
- if (WaitForSingleObject (spr, 1) == WAIT_OBJECT_0)
- res |= EXIT_REPARENTING;
- else if (!(res & EXIT_REPARENTING))
- {
- MALLOC_CHECK;
- close_all_files ();
- MALLOC_CHECK;
- }
- break;
- case WAIT_OBJECT_0 + 1:
- sigproc_printf ("signal arrived");
- timeout = 10;
- goto waitfor;
- case WAIT_OBJECT_0 + 2:
- res = EXIT_REPARENTING;
- MALLOC_CHECK;
- ForceCloseHandle (spr);
- MALLOC_CHECK;
- if (!parent_alive)
- {
- nwait = 1;
- sigproc_terminate ();
- goto waitfor;
+ case WAIT_TIMEOUT:
+ syscall_printf ("WFMO timed out after signal");
+ if (WaitForSingleObject (pi.hProcess, 0) != WAIT_OBJECT_0)
+ {
+ sigproc_printf ("subprocess still alive after signal");
+ res = exec_exit;
+ }
+ else
+ {
+ sigproc_printf ("subprocess exited after signal");
+ case WAIT_OBJECT_0:
+ sigproc_printf ("subprocess exited");
+ if (!GetExitCodeProcess (pi.hProcess, &res))
+ res = exec_exit;
+ exited = TRUE;
+ }
+ if (nwait > 2)
+ if (WaitForSingleObject (spr, 1) == WAIT_OBJECT_0)
+ res |= EXIT_REPARENTING;
+ else if (!(res & EXIT_REPARENTING))
+ {
+ MALLOC_CHECK;
+ close_all_files ();
+ MALLOC_CHECK;
+ }
+ break;
+ case WAIT_OBJECT_0 + 1:
+ res = EXIT_REPARENTING;
+ MALLOC_CHECK;
+ ForceCloseHandle (spr);
+ MALLOC_CHECK;
+ if (!parent_alive)
+ {
+ nwait = 1;
+ sigproc_terminate ();
+ continue;
+ }
+ break;
+ case WAIT_FAILED:
+ DWORD r;
+ system_printf ("wait failed: nwait %d, pid %d, winpid %d, %E",
+ nwait, myself->pid, myself->dwProcessId);
+ system_printf ("waitbuf[0] %p %d", waitbuf[0],
+ GetHandleInformation (waitbuf[0], &r));
+ system_printf ("waitbuf[1] %p = %d", waitbuf[1],
+ GetHandleInformation (waitbuf[1], &r));
+ set_errno (ECHILD);
+ return -1;
}
break;
- case WAIT_FAILED:
- DWORD r;
- system_printf ("wait failed: nwait %d, pid %d, winpid %d, %E",
- nwait, myself->pid, myself->dwProcessId);
- system_printf ("waitbuf[0] %p %d", waitbuf[0],
- GetHandleInformation (waitbuf[0], &r));
- system_printf ("waitbuf[1] %p = %d", waitbuf[1],
- GetHandleInformation (waitbuf[1], &r));
- set_errno (ECHILD);
- return -1;
}
if (nwait > 2)