diff options
author | madhum <madhum@13f79535-47bb-0310-9956-ffa450edef68> | 2004-04-21 01:01:28 +0000 |
---|---|---|
committer | madhum <madhum@13f79535-47bb-0310-9956-ffa450edef68> | 2004-04-21 01:01:28 +0000 |
commit | 12f0b19c90aa2f723c663add3c23796a33248202 (patch) | |
tree | dc7f48a62bcd34387c4812b8497b9ca4bfec034e /threadproc | |
parent | c8434b1a1ae0f73af3816374812368db7cca8cb9 (diff) | |
download | libapr-12f0b19c90aa2f723c663add3c23796a33248202.tar.gz |
Added two new functions apr_signal_block and apr_signal_unblock to
block/unblock only certain signals.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@65071 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'threadproc')
-rw-r--r-- | threadproc/unix/signals.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/threadproc/unix/signals.c b/threadproc/unix/signals.c index ae87a861b..9b0174cdd 100644 --- a/threadproc/unix/signals.c +++ b/threadproc/unix/signals.c @@ -423,4 +423,50 @@ APR_DECLARE(apr_status_t) apr_setup_signal_thread(void) return rv; } +APR_DECLARE(apr_status_t) apr_signal_block(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_signal_unblock(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 |