pthread_sigmask bug

Eric Blake eblake@redhat.com
Sat Jul 9 13:19:00 GMT 2011


On 07/09/2011 12:58 AM, Corinna Vinschen wrote:
> On Jul  8 17:16, Eric Blake wrote:
>> The current implementation of pthread_sigmask violates POSIX:
> 
> PTC?

 winsup/cygwin/ChangeLog |    6 ++++++
 winsup/cygwin/signal.cc |   10 ++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)

2011-07-09  Eric Blake  <eblake@redhat.com>

	* signal.cc (handle_sigprocmask): Return error rather than
	setting errno, for pthread_sigmask.
	(sigprocmask): Adjust caller.

diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc
index 9c920d0..4c472fd 100644
--- a/winsup/cygwin/signal.cc
+++ b/winsup/cygwin/signal.cc
@@ -174,7 +174,10 @@ usleep (useconds_t useconds)
 extern "C" int
 sigprocmask (int how, const sigset_t *set, sigset_t *oldset)
 {
-  return handle_sigprocmask (how, set, oldset, _my_tls.sigmask);
+  int res = handle_sigprocmask (how, set, oldset, _my_tls.sigmask);
+  if (res)
+    set_errno (res);
+  return res ? -1 : 0;
 }

 int __stdcall
@@ -184,13 +187,12 @@ handle_sigprocmask (int how, const sigset_t *set,
sigset_t *oldset, sigset_t& op
   if (how != SIG_BLOCK && how != SIG_UNBLOCK && how != SIG_SETMASK)
     {
       syscall_printf ("Invalid how value %d", how);
-      set_errno (EINVAL);
-      return -1;
+      return EINVAL;
     }

   myfault efault;
   if (efault.faulted (EFAULT))
-    return -1;
+    return EFAULT;

   if (oldset)
     *oldset = opmask;

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20110709/919f9d15/attachment.sig>


More information about the Cygwin-patches mailing list