summary refs log tree commit diff
path: root/sysdeps/posix/sigset.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-04-23 19:05:33 +0000
committerUlrich Drepper <drepper@redhat.com>2006-04-23 19:05:33 +0000
commit727a6832f033c711fe75c5f742b07087ef5b5133 (patch)
tree9662b191a016789a94526defe03297d48686e19f /sysdeps/posix/sigset.c
parent9055724a92433ffa4c36f93d918ee1b3dfa1d6f7 (diff)
downloadglibc-727a6832f033c711fe75c5f742b07087ef5b5133.tar.gz
glibc-727a6832f033c711fe75c5f742b07087ef5b5133.tar.xz
glibc-727a6832f033c711fe75c5f742b07087ef5b5133.zip
[BZ #1951]
2006-04-23  Ulrich Drepper  <drepper@redhat.com>
	[BZ #1951]
	* sysdeps/posix/sigset.c (sigset): Return correct value reflecting
	previous signal state.
	* signal/Makefile (tests): Add tst-sigset2.
	* signal/tst-sigset2.c: New file.
Diffstat (limited to 'sysdeps/posix/sigset.c')
-rw-r--r--sysdeps/posix/sigset.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/sysdeps/posix/sigset.c b/sysdeps/posix/sigset.c
index 31e39d78b5..8f96e3d610 100644
--- a/sysdeps/posix/sigset.c
+++ b/sysdeps/posix/sigset.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 2000, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2000, 2005, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -29,8 +29,10 @@ sigset (sig, disp)
      int sig;
      __sighandler_t disp;
 {
-  struct sigaction act, oact;
+  struct sigaction act;
+  struct sigaction oact;
   sigset_t set;
+  sigset_t oset;
 
 #ifdef SIG_HOLD
   /* Handle SIG_HOLD first.  */
@@ -45,10 +47,18 @@ sigset (sig, disp)
 	return SIG_ERR;
 
       /* Add the signal set to the current signal mask.  */
-      if (__sigprocmask (SIG_BLOCK, &set, NULL) < 0)
+      if (__sigprocmask (SIG_BLOCK, &set, &oset) < 0)
 	return SIG_ERR;
 
-      return SIG_HOLD;
+      /* If the signal was already blocked signal this to the caller.  */
+      if (__sigismember (&oset, sig))
+	return SIG_HOLD;
+
+      /* We need to determine whether a specific handler is installed.  */
+      if (__sigaction (sig, NULL, &oact) < 0)
+	return SIG_ERR;
+
+      return oact.sa_handler;
     }
 #endif	/* SIG_HOLD */
 
@@ -75,8 +85,9 @@ sigset (sig, disp)
     return SIG_ERR;
 
   /* Remove the signal set from the current signal mask.  */
-  if (__sigprocmask (SIG_UNBLOCK, &set, NULL) < 0)
+  if (__sigprocmask (SIG_UNBLOCK, &set, &oset) < 0)
     return SIG_ERR;
 
-  return oact.sa_handler;
+  /* If the signal was already blocked return SIG_HOLD.  */
+  return __sigismember (&oset, sig) ? SIG_HOLD : oact.sa_handler;
 }