diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index a4bb6787b..8c8e068ff 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,13 @@ +2015-02-23 Corinna Vinschen + + * cygwait.h (enum cw_wait_mask): Add cw_sig_restart. Add comments + to explain the meaning of the possible values. + * cygwait.cc (is_cw_sig_restart): Define. + (is_cw_sig_handle): Check for cw_sig_restart as well. + (cygwait): Restart always if cw_sig_restart is set. + * thread.cc (pthread::join): Call cygwait with cw_sig_restart flag + to avoid having to handle signals at all. + 2015-02-23 Corinna Vinschen * cygwait.cc (cygwait): Move setting res to WAIT_SIGNALED to clarify diff --git a/winsup/cygwin/cygwait.cc b/winsup/cygwin/cygwait.cc index 4d2b8a745..71d30d164 100644 --- a/winsup/cygwin/cygwait.cc +++ b/winsup/cygwin/cygwait.cc @@ -18,8 +18,10 @@ #define is_cw_sig (mask & cw_sig) #define is_cw_sig_eintr (mask & cw_sig_eintr) #define is_cw_sig_cont (mask & cw_sig_cont) +#define is_cw_sig_restart (mask & cw_sig_restart) -#define is_cw_sig_handle (mask & (cw_sig | cw_sig_eintr | cw_sig_cont)) +#define is_cw_sig_handle (mask & (cw_sig | cw_sig_eintr \ + | cw_sig_cont | cw_sig_restart)) LARGE_INTEGER cw_nowait_storage; @@ -88,7 +90,7 @@ cygwait (HANDLE object, PLARGE_INTEGER timeout, unsigned mask) continue; if (is_cw_sig_eintr || (is_cw_sig_cont && sig == SIGCONT)) ; - else if (_my_tls.call_signal_handler ()) + else if (_my_tls.call_signal_handler () || is_cw_sig_restart) continue; res = WAIT_SIGNALED; /* caller will deal with signals */ } diff --git a/winsup/cygwin/cygwait.h b/winsup/cygwin/cygwait.h index 496817bcf..1240f5404 100644 --- a/winsup/cygwin/cygwait.h +++ b/winsup/cygwin/cygwait.h @@ -1,7 +1,7 @@ /* cygwait.h - Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 - Red Hat, Inc. + Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, + 2015 Red Hat, Inc. This file is part of Cygwin. @@ -16,11 +16,12 @@ enum cw_wait_mask { - cw_cancel = 0x0001, - cw_cancel_self = 0x0002, - cw_sig = 0x0004, - cw_sig_eintr = 0x0008, - cw_sig_cont = 0x0010 + cw_cancel = 0x0001, /* Cancellation point. Return to caller. */ + cw_cancel_self = 0x0002, /* Cancellation point. Cancel self. */ + cw_sig = 0x0004, /* Handle signals. */ + cw_sig_eintr = 0x0008, /* Caller handles signals. */ + cw_sig_cont = 0x0010, /* Caller handles SIGCONT. */ + cw_sig_restart = 0x0020 /* Restart even if SA_RESTART isn't set. */ }; extern LARGE_INTEGER cw_nowait_storage; diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index 1ac338b4b..a08a733d7 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -1,7 +1,7 @@ /* thread.cc: Locking and threading module functions Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, - 2009, 2010, 2011, 2012, 2013, 2014 Red Hat, Inc. + 2009, 2010, 2011, 2012, 2013, 2014, 2015 Red Hat, Inc. This file is part of Cygwin. @@ -2399,7 +2399,8 @@ pthread::join (pthread_t *thread, void **return_val) (*thread)->attr.joinable = PTHREAD_CREATE_DETACHED; (*thread)->mutex.unlock (); - switch (cygwait ((*thread)->win32_obj_id, cw_infinite, cw_sig | cw_cancel)) + switch (cygwait ((*thread)->win32_obj_id, cw_infinite, + cw_sig | cw_sig_restart | cw_cancel)) { case WAIT_OBJECT_0: if (return_val)