Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2004-02-26 08:10:49 +0300
committerChristopher Faylor <me@cgf.cx>2004-02-26 08:10:49 +0300
commitca713cfab35fe144b73240ebe2c333c36fd7a214 (patch)
treefea3c6ad34283801c717108aae1f7ff6729f0b92 /winsup/cygwin/thread.cc
parentf9e19c093165d7c75bd9d04204845ed53b8ff0a8 (diff)
* exceptions.cc (setup_handler): Signal event for any sigwaitinfo if it exists
to force signal to be handled. Zero event here to prevent races. * signal.cc (sigwaitinfo): Use local handle value for everything since signal thread could zero event element at any time. Detect when awaking due to thread not in mask and set return value and errno accordingly. Don't set signal number to zero unless we've recognized the signal. * sigproc.cc (sigq): Rename from sigqueue throughout. * thread.cc (pthread::join): Handle signals received while waiting for thread to terminate. * cygwin.din: Export sighold, sigqueue. * exceptions.cc (sighold): Define new function. * signal.cc (handle_sigprocmask): Set correct errno for invalid signal. Simplify debugging output. (sigqueue): Define new function. * include/cygwin/signal.h (sighold): Declare new function. (sigqueue): Ditto. * include/cygwin/version.h: Bump API minor version number. * include/limits.h (TIMER_MAX): Define. (_POSIX_TIMER_MAX): Ditto.
Diffstat (limited to 'winsup/cygwin/thread.cc')
-rw-r--r--winsup/cygwin/thread.cc43
1 files changed, 25 insertions, 18 deletions
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index 7e102fed8..e119129d1 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -2181,24 +2181,31 @@ pthread::join (pthread_t *thread, void **return_val)
(*thread)->attr.joinable = PTHREAD_CREATE_DETACHED;
(*thread)->mutex.unlock ();
- switch (cancelable_wait ((*thread)->win32_obj_id, INFINITE, false, false))
- {
- case WAIT_OBJECT_0:
- if (return_val)
- *return_val = (*thread)->return_ptr;
- delete (*thread);
- break;
- case WAIT_CANCELED:
- // set joined thread back to joinable since we got canceled
- (*thread)->joiner = NULL;
- (*thread)->attr.joinable = PTHREAD_CREATE_JOINABLE;
- joiner->cancel_self ();
- // never reached
- break;
- default:
- // should never happen
- return EINVAL;
- }
+ bool loop = false;
+ do
+ switch (cancelable_wait ((*thread)->win32_obj_id, INFINITE, false, true))
+ {
+ case WAIT_OBJECT_0:
+ if (return_val)
+ *return_val = (*thread)->return_ptr;
+ delete (*thread);
+ break;
+ case WAIT_SIGNALED:
+ _my_tls.call_signal_handler ();
+ loop = true;
+ break;
+ case WAIT_CANCELED:
+ // set joined thread back to joinable since we got canceled
+ (*thread)->joiner = NULL;
+ (*thread)->attr.joinable = PTHREAD_CREATE_JOINABLE;
+ joiner->cancel_self ();
+ // never reached
+ break;
+ default:
+ // should never happen
+ return EINVAL;
+ }
+ while (loop);
}
return 0;