diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index f567cbeac..a628eb518 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,15 @@ +2006-03-21 Christopher Faylor + + * 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. + 2006-03-20 Christopher Faylor * dcrt0.cc (dll_crt0_0): Call SetErrorMode earlier. diff --git a/winsup/cygwin/child_info.h b/winsup/cygwin/child_info.h index e6599e845..c9f6eae2f 100644 --- a/winsup/cygwin/child_info.h +++ b/winsup/cygwin/child_info.h @@ -21,7 +21,7 @@ enum child_info_types enum child_status { _CI_STRACED = 0x01, - _CI_ISCYGWIN = 0x0 + _CI_ISCYGWIN = 0x02 }; #define OPROC_MAGIC_MASK 0xff00ff00 @@ -36,7 +36,7 @@ enum child_status #define EXEC_MAGIC_SIZE sizeof(child_info) /* Change this value if you get a message indicating that it is out-of-sync. */ -#define CURR_CHILD_INFO_MAGIC 0xa189e57U +#define CURR_CHILD_INFO_MAGIC 0x1630848cU /* NOTE: Do not make gratuitous changes to the names or organization of the below class. The layout is checksummed to determine compatibility between @@ -66,8 +66,8 @@ public: void ready (bool); bool sync (int, HANDLE&, DWORD) __attribute__ ((regparm (3))); DWORD proc_retry (HANDLE) __attribute__ ((regparm (2))); - bool isstraced () const {return flag & _CI_STRACED;} - bool iscygwin () const {return flag & _CI_ISCYGWIN;} + bool isstraced () const {return !!(flag & _CI_STRACED);} + bool iscygwin () const {return !!(flag & _CI_ISCYGWIN);} }; class mount_info; diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 279223e58..11058deef 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -104,9 +104,9 @@ init_console_handler (bool install_handler) { BOOL res; - SetConsoleCtrlHandler (ctrl_c_handler, FALSE); - if (wincap.has_null_console_handler_routine ()) - SetConsoleCtrlHandler (NULL, FALSE); + SetConsoleCtrlHandler (ctrl_c_handler, FALSE); + if (wincap.has_null_console_handler_routine ()) + SetConsoleCtrlHandler (NULL, FALSE); if (install_handler) res = SetConsoleCtrlHandler (ctrl_c_handler, TRUE); else if (wincap.has_null_console_handler_routine ()) diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 00a6cf90e..51c756934 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -780,16 +780,16 @@ child_info::child_info (unsigned in_cb, child_info_types chtype, bool need_subpr type = chtype; fhandler_union_cb = sizeof (fhandler_union); user_h = cygwin_user_h; - if (need_subproc_ready) - subproc_ready = CreateEvent (&sec_all, FALSE, FALSE, NULL); - sigproc_printf ("subproc_ready %p", subproc_ready); - cygheap = ::cygheap; - cygheap_max = ::cygheap_max; - flag = 0; if (strace.attached ()) flag |= _CI_STRACED; if (need_subproc_ready) - flag |= _CI_ISCYGWIN; + { + subproc_ready = CreateEvent (&sec_all, FALSE, FALSE, NULL); + flag |= _CI_ISCYGWIN; + } + sigproc_printf ("subproc_ready %p", subproc_ready); + cygheap = ::cygheap; + cygheap_max = ::cygheap_max; retry = child_info::retry_count; /* Create an inheritable handle to pass to the child process. This will allow the child to duplicate handles from the parent to itself. */ 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;