From 76ef40d69f3651f01b3e2ffdeb470593d62e04b0 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Wed, 22 Mar 2006 03:20:28 +0000 Subject: * child_info.h (child_status): Fix typo which made it impossible to set iscygwin. (child_info::isstraced): Booleanize. (child_info::iscygwin): Ditto. * sigproc.cc (child_info::child_info): Minor cleanup of flag setting. * spawn.cc (spawn_guts): Only close_all_files when we know the process has started successfully. * exceptions.cc (init_console_handler): Fix indentation. --- winsup/cygwin/spawn.cc | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'winsup/cygwin/spawn.cc') diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 3a0209764..d61fb5984 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -777,8 +777,6 @@ loop: strace.execing = 1; myself.hProcess = hExeced = pi.hProcess; strcpy (myself->progname, real_path); // FIXME: race? - if (!looped) - close_all_files (true); sigproc_printf ("new process name %s", myself->progname); /* If wr_proc_pipe doesn't exist then this process was not started by a cygwin process. So, we need to wait around until the process we've just "execed" @@ -864,19 +862,25 @@ loop: myself->wr_proc_pipe_owner = GetCurrentProcessId (); myself->wr_proc_pipe = orig_wr_proc_pipe; } - if (ch.proc_retry (pi.hProcess) == 0) + DWORD res = ch.proc_retry (pi.hProcess); + if (!res) { looped++; goto loop; } + close_all_files (true); } - else if (!myself->wr_proc_pipe - && WaitForSingleObject (pi.hProcess, 0) == WAIT_TIMEOUT) + else { - extern bool is_toplevel_proc; - is_toplevel_proc = true; - myself.remember (false); - waitpid (myself->pid, &res, 0); + close_all_files (true); + if (!myself->wr_proc_pipe + && WaitForSingleObject (pi.hProcess, 0) == WAIT_TIMEOUT) + { + extern bool is_toplevel_proc; + is_toplevel_proc = true; + myself.remember (false); + waitpid (myself->pid, &res, 0); + } } myself.exit (EXITCODE_NOSET); break; -- cgit v1.2.3