Fix sigwait and pthread_kill return values in case of error
* signal.cc (sigwait): Fix return value to reflect errno in case of error according to POSIX. Never return EINTR. * thread.cc (pthread_kill): Return errno if sig_send failed. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
		| @@ -1,3 +1,9 @@ | |||||||
|  | 2015-10-30  Corinna Vinschen  <corinna@vinschen.de> | ||||||
|  |  | ||||||
|  | 	* signal.cc (sigwait): Fix return value to reflect errno in case of | ||||||
|  | 	error according to POSIX.  Never return EINTR. | ||||||
|  | 	* thread.cc (pthread_kill): Return errno if sig_send failed. | ||||||
|  |  | ||||||
| 2015-10-29  Qian Hong  <qhong@codeweavers.com> | 2015-10-29  Qian Hong  <qhong@codeweavers.com> | ||||||
|  |  | ||||||
| 	* init.cc (munge_threadfunc): Check that we're actually replacing | 	* init.cc (munge_threadfunc): Check that we're actually replacing | ||||||
|   | |||||||
| @@ -53,3 +53,7 @@ Bug Fixes | |||||||
|  |  | ||||||
| - Fix a potential SEGV on (at least) Wine. | - Fix a potential SEGV on (at least) Wine. | ||||||
|   Addresses: https://cygwin.com/ml/cygwin/2015-10/msg00018.html |   Addresses: https://cygwin.com/ml/cygwin/2015-10/msg00018.html | ||||||
|  |  | ||||||
|  | - Fix sigwait(3) to return errno instead of -1 and never to return with EINTR. | ||||||
|  |  | ||||||
|  | - Fix pthread_kill(3) to return errno instead of -1. | ||||||
|   | |||||||
| @@ -557,10 +557,16 @@ siginterrupt (int sig, int flag) | |||||||
| extern "C" int | extern "C" int | ||||||
| sigwait (const sigset_t *set, int *sig_ptr) | sigwait (const sigset_t *set, int *sig_ptr) | ||||||
| { | { | ||||||
|   int sig = sigwaitinfo (set, NULL); |   int sig; | ||||||
|  |  | ||||||
|  |   do | ||||||
|  |     { | ||||||
|  |       sig = sigwaitinfo (set, NULL); | ||||||
|  |     } | ||||||
|  |   while (sig == -1 && get_errno () == EINTR); | ||||||
|   if (sig > 0) |   if (sig > 0) | ||||||
|     *sig_ptr = sig; |     *sig_ptr = sig; | ||||||
|   return sig > 0 ? 0 : -1; |   return sig > 0 ? 0 : get_errno (); | ||||||
| } | } | ||||||
|  |  | ||||||
| extern "C" int | extern "C" int | ||||||
|   | |||||||
| @@ -3056,7 +3056,11 @@ pthread_kill (pthread_t thread, int sig) | |||||||
|   if (!thread->valid) |   if (!thread->valid) | ||||||
|     rval = ESRCH; |     rval = ESRCH; | ||||||
|   else if (sig) |   else if (sig) | ||||||
|     rval = sig_send (NULL, si, thread->cygtls); |     { | ||||||
|  |       rval = sig_send (NULL, si, thread->cygtls); | ||||||
|  |       if (rval == -1) | ||||||
|  | 	rval = get_errno (); | ||||||
|  |     } | ||||||
|   else |   else | ||||||
|     switch (WaitForSingleObject (thread->win32_obj_id, 0)) |     switch (WaitForSingleObject (thread->win32_obj_id, 0)) | ||||||
|       { |       { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user