diff options
| author | Stefan Monnier | 2012-03-25 16:37:21 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2012-03-25 16:37:21 -0400 |
| commit | 699c782b7668c44d0fa4446331b0590a6d5dac82 (patch) | |
| tree | 5dcce364741d0761920a3d274b0fc8aba4103d45 /lib/sigprocmask.c | |
| parent | 98fb480ee31bf74cf554044f60f21df16566dd7f (diff) | |
| parent | e99a9b8bdccadded1f6fae88ee7a2a93dfd4eacf (diff) | |
| download | emacs-pending.tar.gz emacs-pending.zip | |
Merge from trunkpending
Diffstat (limited to 'lib/sigprocmask.c')
| -rw-r--r-- | lib/sigprocmask.c | 55 |
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 | ||
| 59 | typedef void (*handler_t) (int); | 63 | typedef void (*handler_t) (int); |
| 60 | 64 | ||
| 65 | #if HAVE_MSVC_INVALID_PARAMETER_HANDLER | ||
| 66 | static inline handler_t | ||
| 67 | signal_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. */ |
| 307 | int | 334 | int |
| 308 | rpl_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 |