From f02400f7c9db8176a7cc49eb8e4b6450ae5901c2 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Wed, 15 Mar 2006 00:29:14 +0000 Subject: [PATCH] * child_info.h (child_info_fork::fork_retry): Declare new function. * dcrt0.cc (child_info_fork::fork_retry): Define new function. * fork.cc (frok::parent): Move retry decision into child_info_fork::fork_retry and honor what it tells us to do. * sigproc.cc (sig_send): Unhold signals on __SIGEXIT. --- winsup/cygwin/ChangeLog | 8 ++++++++ winsup/cygwin/child_info.h | 3 ++- winsup/cygwin/dcrt0.cc | 20 ++++++++++++++++++++ winsup/cygwin/fork.cc | 9 +++------ winsup/cygwin/sigproc.cc | 2 +- 5 files changed, 34 insertions(+), 8 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 3a72e7d21..480074b28 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,11 @@ +2006-03-14 Christopher Faylor + + * child_info.h (child_info_fork::fork_retry): Declare new function. + * dcrt0.cc (child_info_fork::fork_retry): Define new function. + * fork.cc (frok::parent): Move retry decision into + child_info_fork::fork_retry and honor what it tells us to do. + * sigproc.cc (sig_send): Unhold signals on __SIGEXIT. + 2006-03-14 Christopher Faylor * fork.cc (frok::parent): Improve error message. diff --git a/winsup/cygwin/child_info.h b/winsup/cygwin/child_info.h index 03e8af58f..87da6e453 100644 --- a/winsup/cygwin/child_info.h +++ b/winsup/cygwin/child_info.h @@ -29,7 +29,7 @@ enum child_info_types #define EXEC_MAGIC_SIZE sizeof(child_info) -#define CURR_CHILD_INFO_MAGIC 0x4160e87bU +#define CURR_CHILD_INFO_MAGIC 0x88e640f7U /* NOTE: Do not make gratuitous changes to the names or organization of the below class. The layout is checksummed to determine compatibility between @@ -72,6 +72,7 @@ public: child_info_fork (); void handle_fork (); bool handle_failure (DWORD); + DWORD fork_retry (HANDLE); }; class fhandler_base; diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 46fdf926c..26a749c0a 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -642,6 +642,26 @@ get_cygwin_startup_info () return res; } +DWORD +child_info_fork::fork_retry (HANDLE h) +{ + DWORD exit_code; + if (!GetExitCodeProcess (h, &exit_code)) + return STILL_ACTIVE; /* should never happen */ + switch (exit_code) + { + case STATUS_CONTROL_C_EXIT: + if (retry-- > 0) + return 0; + break; + case EXITCODE_RETRY: + if (retry-- > 0) + return 0; + break; + } + return exit_code; +} + bool child_info_fork::handle_failure (DWORD err) { diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index 7aab31520..260960895 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -326,12 +326,9 @@ frok::parent (void *stack_here) /* Wait for subproc to initialize itself. */ if (!ch.sync (pi.dwProcessId, pi.hProcess, FORK_WAIT_TIMEOUT)) { - DWORD exit_code; - if (GetExitCodeProcess (pi.hProcess, &exit_code) && exit_code == EXITCODE_RETRY) - { - ch.retry--; - continue; - } + DWORD exit_code = ch.fork_retry (pi.hProcess); + if (!exit_code) + continue; this_errno = EAGAIN; /* Not thread safe, but do we care? */ static char buf[sizeof("died waiting for longjmp before " diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 0b22495c9..4cd538c32 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -515,7 +515,7 @@ sig_send (_pinfo *p, int sig) /* nothing */; else if (sig == __SIGFLUSH || sig == __SIGFLUSHFAST) return 0; - else if (sig == __SIGNOHOLD) + else if (sig == __SIGNOHOLD || sig == __SIGEXIT) { SetEvent (sigCONT); sigheld = false;