aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sigprocmask.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sigprocmask.c')
-rw-r--r--lib/sigprocmask.c55
1 files changed, 37 insertions, 18 deletions
diff --git a/lib/sigprocmask.c b/lib/sigprocmask.c
index 6780a37b14f..e75c7576cdf 100644
--- a/lib/sigprocmask.c
+++ b/lib/sigprocmask.c
@@ -24,6 +24,10 @@
24#include <stdint.h> 24#include <stdint.h>
25#include <stdlib.h> 25#include <stdlib.h>
26 26
27#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
28# include "msvc-inval.h"
29#endif
30
27/* We assume that a platform without POSIX signal blocking functions 31/* We assume that a platform without POSIX signal blocking functions
28 also does not have the POSIX sigaction() function, only the 32 also does not have the POSIX sigaction() function, only the
29 signal() function. We also assume signal() has SysV semantics, 33 signal() function. We also assume signal() has SysV semantics,
@@ -58,6 +62,28 @@
58 62
59typedef void (*handler_t) (int); 63typedef void (*handler_t) (int);
60 64
65#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
66static inline handler_t
67signal_nothrow (int sig, handler_t handler)
68{
69 handler_t result;
70
71 TRY_MSVC_INVAL
72 {
73 result = signal (sig, handler);
74 }
75 CATCH_MSVC_INVAL
76 {
77 result = SIG_ERR;
78 errno = EINVAL;
79 }
80 DONE_MSVC_INVAL;
81
82 return result;
83}
84# define signal signal_nothrow
85#endif
86
61/* Handling of gnulib defined signals. */ 87/* Handling of gnulib defined signals. */
62 88
63#if GNULIB_defined_SIGPIPE 89#if GNULIB_defined_SIGPIPE
@@ -80,6 +106,7 @@ ext_signal (int sig, handler_t handler)
80 return signal (sig, handler); 106 return signal (sig, handler);
81 } 107 }
82} 108}
109# undef signal
83# define signal ext_signal 110# define signal ext_signal
84#endif 111#endif
85 112
@@ -303,27 +330,19 @@ rpl_signal (int sig, handler_t handler)
303} 330}
304 331
305#if GNULIB_defined_SIGPIPE 332#if GNULIB_defined_SIGPIPE
306/* Raise the signal SIG. */ 333/* Raise the signal SIGPIPE. */
307int 334int
308rpl_raise (int sig) 335_gl_raise_SIGPIPE (void)
309# undef raise
310{ 336{
311 switch (sig) 337 if (blocked_set & (1U << SIGPIPE))
338 pending_array[SIGPIPE] = 1;
339 else
312 { 340 {
313 case SIGPIPE: 341 handler_t handler = SIGPIPE_handler;
314 if (blocked_set & (1U << sig)) 342 if (handler == SIG_DFL)
315 pending_array[sig] = 1; 343 exit (128 + SIGPIPE);
316 else 344 else if (handler != SIG_IGN)
317 { 345 (*handler) (SIGPIPE);
318 handler_t handler = SIGPIPE_handler;
319 if (handler == SIG_DFL)
320 exit (128 + SIGPIPE);
321 else if (handler != SIG_IGN)
322 (*handler) (sig);
323 }
324 return 0;
325 default: /* System defined signal */
326 return raise (sig);
327 } 346 }
328} 347}
329#endif 348#endif