You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by "Mathihalli, Madhusudan" <ma...@hp.com> on 2004/04/20 03:31:50 UTC

[PATCH] New api's apr_block_signal and apr_unblock_signal

Hi,
	Since a lot of the async signals are blocked by default, I thought
it'll be good to provide a apr_(un)block_signal() api for those who want to block/unblock only select signals. Here's a patch to do that.

Any comments -

-Madhu

Index: signals.c
===================================================================
RCS file: /home/cvs/apr/threadproc/unix/signals.c,v
retrieving revision 1.57
diff -u -r1.57 signals.c
--- signals.c   13 Feb 2004 09:38:37 -0000      1.57
+++ signals.c   20 Apr 2004 01:27:17 -0000
@@ -423,4 +423,50 @@
     return rv;
 }
 
+APR_DECLARE(apr_status_t) apr_block_signal(int signum)
+{
+    sigset_t sig_mask;
+    int rv;
+
+    sigemptyset(&sig_mask);
+
+    sigaddset(&sig_mask, signum);
+
+#if defined(SIGPROCMASK_SETS_THREAD_MASK)
+    if ((rv = sigprocmask(SIG_BLOCK, &sig_mask, NULL)) != 0) {
+        rv = errno;
+    }
+#else
+    if ((rv = pthread_sigmask(SIG_BLOCK, &sig_mask, NULL)) != 0) {
+#ifdef PTHREAD_SETS_ERRNO
+        rv = errno;
+#endif
+    }
+#endif
+    return rv;
+}
+
+APR_DECLARE(apr_status_t) apr_unblock_signal(int signum)
+{
+    sigset_t sig_mask;
+    int rv;
+
+    sigemptyset(&sig_mask);
+
+    sigaddset(&sig_mask, signum);
+
+#if defined(SIGPROCMASK_SETS_THREAD_MASK)
+    if ((rv = sigprocmask(SIG_UNBLOCK, &sig_mask, NULL)) != 0) {
+        rv = errno;
+    }
+#else
+    if ((rv = pthread_sigmask(SIG_UNBLOCK, &sig_mask, NULL)) != 0) {
+#ifdef PTHREAD_SETS_ERRNO
+        rv = errno;
+#endif
+    }
+#endif
+    return rv;
+}
+
 #endif

Re: [PATCH] New api's apr_block_signal and apr_unblock_signal

Posted by Cliff Woolley <jw...@virginia.edu>.
On Mon, 19 Apr 2004, Mathihalli, Madhusudan wrote:

> 	Since a lot of the async signals are blocked by default, I thought
> it'll be good to provide a apr_(un)block_signal() api for those who want
> to block/unblock only select signals. Here's a patch to do that.

Is this portable?  (Admitting my ignorance of the Win32 API here.)

PS: the names should be apr_signal_block and apr_signal_unblock instead.

--Cliff

Re: [PATCH] New api's apr_block_signal and apr_unblock_signal

Posted by Joe Orton <jo...@manyfish.co.uk>.
Missed commit to apr_signal.h?

threadproc/unix/signals.c:427: warning: no previous prototype for `apr_signal_block'
threadproc/unix/signals.c:450: warning: no previous prototype for `apr_signal_unblock'