aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/um/os-Linux/signal.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c
index 91a35da5fe90..0fb0cc8d4757 100644
--- a/arch/um/os-Linux/signal.c
+++ b/arch/um/os-Linux/signal.c
@@ -63,7 +63,7 @@ static void sig_handler_common(int sig, struct sigcontext *sc)
63#define SIGVTALRM_MASK (1 << SIGVTALRM_BIT) 63#define SIGVTALRM_MASK (1 << SIGVTALRM_BIT)
64 64
65static int signals_enabled; 65static int signals_enabled;
66static unsigned int pending; 66static unsigned int signals_pending;
67 67
68void sig_handler(int sig, struct sigcontext *sc) 68void sig_handler(int sig, struct sigcontext *sc)
69{ 69{
@@ -71,7 +71,7 @@ void sig_handler(int sig, struct sigcontext *sc)
71 71
72 enabled = signals_enabled; 72 enabled = signals_enabled;
73 if (!enabled && (sig == SIGIO)) { 73 if (!enabled && (sig == SIGIO)) {
74 pending |= SIGIO_MASK; 74 signals_pending |= SIGIO_MASK;
75 return; 75 return;
76 } 76 }
77 77
@@ -99,7 +99,7 @@ void alarm_handler(int sig, struct sigcontext *sc)
99 99
100 enabled = signals_enabled; 100 enabled = signals_enabled;
101 if (!signals_enabled) { 101 if (!signals_enabled) {
102 pending |= SIGVTALRM_MASK; 102 signals_pending |= SIGVTALRM_MASK;
103 return; 103 return;
104 } 104 }
105 105
@@ -125,16 +125,6 @@ void set_sigstack(void *sig_stack, int size)
125 panic("enabling signal stack failed, errno = %d\n", errno); 125 panic("enabling signal stack failed, errno = %d\n", errno);
126} 126}
127 127
128void remove_sigstack(void)
129{
130 stack_t stack = ((stack_t) { .ss_flags = SS_DISABLE,
131 .ss_sp = NULL,
132 .ss_size = 0 });
133
134 if (sigaltstack(&stack, NULL) != 0)
135 panic("disabling signal stack failed, errno = %d\n", errno);
136}
137
138void (*handlers[_NSIG])(int sig, struct sigcontext *sc); 128void (*handlers[_NSIG])(int sig, struct sigcontext *sc);
139 129
140void handle_signal(int sig, struct sigcontext *sc) 130void handle_signal(int sig, struct sigcontext *sc)
@@ -213,13 +203,14 @@ void set_handler(int sig, void (*handler)(int), int flags, ...)
213 203
214int change_sig(int signal, int on) 204int change_sig(int signal, int on)
215{ 205{
216 sigset_t sigset, old; 206 sigset_t sigset;
217 207
218 sigemptyset(&sigset); 208 sigemptyset(&sigset);
219 sigaddset(&sigset, signal); 209 sigaddset(&sigset, signal);
220 if (sigprocmask(on ? SIG_UNBLOCK : SIG_BLOCK, &sigset, &old) < 0) 210 if (sigprocmask(on ? SIG_UNBLOCK : SIG_BLOCK, &sigset, NULL) < 0)
221 return -errno; 211 return -errno;
222 return !sigismember(&old, signal); 212
213 return 0;
223} 214}
224 215
225void block_signals(void) 216void block_signals(void)
@@ -244,26 +235,26 @@ void unblock_signals(void)
244 /* 235 /*
245 * We loop because the IRQ handler returns with interrupts off. So, 236 * We loop because the IRQ handler returns with interrupts off. So,
246 * interrupts may have arrived and we need to re-enable them and 237 * interrupts may have arrived and we need to re-enable them and
247 * recheck pending. 238 * recheck signals_pending.
248 */ 239 */
249 while(1) { 240 while(1) {
250 /* 241 /*
251 * Save and reset save_pending after enabling signals. This 242 * Save and reset save_pending after enabling signals. This
252 * way, pending won't be changed while we're reading it. 243 * way, signals_pending won't be changed while we're reading it.
253 */ 244 */
254 signals_enabled = 1; 245 signals_enabled = 1;
255 246
256 /* 247 /*
257 * Setting signals_enabled and reading pending must 248 * Setting signals_enabled and reading signals_pending must
258 * happen in this order. 249 * happen in this order.
259 */ 250 */
260 barrier(); 251 barrier();
261 252
262 save_pending = pending; 253 save_pending = signals_pending;
263 if (save_pending == 0) 254 if (save_pending == 0)
264 return; 255 return;
265 256
266 pending = 0; 257 signals_pending = 0;
267 258
268 /* 259 /*
269 * We have pending interrupts, so disable signals, as the 260 * We have pending interrupts, so disable signals, as the