diff options
Diffstat (limited to 'openbsd-compat/sigact.c')
-rw-r--r-- | openbsd-compat/sigact.c | 50 |
1 files changed, 39 insertions, 11 deletions
diff --git a/openbsd-compat/sigact.c b/openbsd-compat/sigact.c index 8b8e4dd2c..d67845cf1 100644 --- a/openbsd-compat/sigact.c +++ b/openbsd-compat/sigact.c | |||
@@ -36,6 +36,7 @@ | |||
36 | /* OPENBSD ORIGINAL: lib/libcurses/base/sigaction.c */ | 36 | /* OPENBSD ORIGINAL: lib/libcurses/base/sigaction.c */ |
37 | 37 | ||
38 | #include "includes.h" | 38 | #include "includes.h" |
39 | #include <errno.h> | ||
39 | #include <signal.h> | 40 | #include <signal.h> |
40 | #include "sigact.h" | 41 | #include "sigact.h" |
41 | 42 | ||
@@ -47,28 +48,39 @@ | |||
47 | int | 48 | int |
48 | sigaction(int sig, struct sigaction *sigact, struct sigaction *osigact) | 49 | sigaction(int sig, struct sigaction *sigact, struct sigaction *osigact) |
49 | { | 50 | { |
50 | return sigvec(sig, &(sigact->sv), &(osigact->sv)); | 51 | return sigvec(sig, sigact ? &sigact->sv : NULL, |
52 | osigact ? &osigact->sv : NULL); | ||
51 | } | 53 | } |
52 | 54 | ||
53 | int | 55 | int |
54 | sigemptyset (sigset_t * mask) | 56 | sigemptyset (sigset_t *mask) |
55 | { | 57 | { |
58 | if (!mask) { | ||
59 | errno = EINVAL; | ||
60 | return -1; | ||
61 | } | ||
56 | *mask = 0; | 62 | *mask = 0; |
57 | return 0; | 63 | return 0; |
58 | } | 64 | } |
59 | 65 | ||
60 | int | 66 | int |
61 | sigprocmask (int mode, sigset_t * mask, sigset_t * omask) | 67 | sigprocmask (int mode, sigset_t *mask, sigset_t *omask) |
62 | { | 68 | { |
63 | sigset_t current = sigsetmask(0); | 69 | sigset_t current = sigsetmask(0); |
64 | 70 | ||
65 | if (omask) *omask = current; | 71 | if (!mask) { |
72 | errno = EINVAL; | ||
73 | return -1; | ||
74 | } | ||
66 | 75 | ||
67 | if (mode==SIG_BLOCK) | 76 | if (omask) |
77 | *omask = current; | ||
78 | |||
79 | if (mode == SIG_BLOCK) | ||
68 | current |= *mask; | 80 | current |= *mask; |
69 | else if (mode==SIG_UNBLOCK) | 81 | else if (mode == SIG_UNBLOCK) |
70 | current &= ~*mask; | 82 | current &= ~*mask; |
71 | else if (mode==SIG_SETMASK) | 83 | else if (mode == SIG_SETMASK) |
72 | current = *mask; | 84 | current = *mask; |
73 | 85 | ||
74 | sigsetmask(current); | 86 | sigsetmask(current); |
@@ -76,28 +88,44 @@ sigprocmask (int mode, sigset_t * mask, sigset_t * omask) | |||
76 | } | 88 | } |
77 | 89 | ||
78 | int | 90 | int |
79 | sigsuspend (sigset_t * mask) | 91 | sigsuspend (sigset_t *mask) |
80 | { | 92 | { |
93 | if (!mask) { | ||
94 | errno = EINVAL; | ||
95 | return -1; | ||
96 | } | ||
81 | return sigpause(*mask); | 97 | return sigpause(*mask); |
82 | } | 98 | } |
83 | 99 | ||
84 | int | 100 | int |
85 | sigdelset (sigset_t * mask, int sig) | 101 | sigdelset (sigset_t *mask, int sig) |
86 | { | 102 | { |
103 | if (!mask) { | ||
104 | errno = EINVAL; | ||
105 | return -1; | ||
106 | } | ||
87 | *mask &= ~sigmask(sig); | 107 | *mask &= ~sigmask(sig); |
88 | return 0; | 108 | return 0; |
89 | } | 109 | } |
90 | 110 | ||
91 | int | 111 | int |
92 | sigaddset (sigset_t * mask, int sig) | 112 | sigaddset (sigset_t *mask, int sig) |
93 | { | 113 | { |
114 | if (!mask) { | ||
115 | errno = EINVAL; | ||
116 | return -1; | ||
117 | } | ||
94 | *mask |= sigmask(sig); | 118 | *mask |= sigmask(sig); |
95 | return 0; | 119 | return 0; |
96 | } | 120 | } |
97 | 121 | ||
98 | int | 122 | int |
99 | sigismember (sigset_t * mask, int sig) | 123 | sigismember (sigset_t *mask, int sig) |
100 | { | 124 | { |
125 | if (!mask) { | ||
126 | errno = EINVAL; | ||
127 | return -1; | ||
128 | } | ||
101 | return (*mask & sigmask(sig)) != 0; | 129 | return (*mask & sigmask(sig)) != 0; |
102 | } | 130 | } |
103 | 131 | ||