summaryrefslogtreecommitdiff
path: root/arch/um/os-Linux
diff options
context:
space:
mode:
authorAl Viro <viro@ftp.linux.org.uk>2011-08-18 20:04:29 +0100
committerRichard Weinberger <richard@nod.at>2011-11-02 14:14:56 +0100
commite87df986ed053d25dbd57b8b137edec5022874f8 (patch)
tree93a955eb7136ddfb30f9a1c99038976729823af4 /arch/um/os-Linux
parentd5c7e8b4ec4795ed0b8943cad8f87801fde371d7 (diff)
um: simplify set_handler()
For one thing, we always block the same signals (IRQ ones - IO, WINCH, VTALRM), so there's no need to pass sa_mask elements in arguments. For another, the flags depend only on whether it's an IRQ signal or not (we add SA_RESTART for them). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'arch/um/os-Linux')
-rw-r--r--arch/um/os-Linux/process.c19
-rw-r--r--arch/um/os-Linux/signal.c22
-rw-r--r--arch/um/os-Linux/skas/process.c3
3 files changed, 18 insertions, 26 deletions
diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c
index c1a8fa74ebb9..075ae920143d 100644
--- a/arch/um/os-Linux/process.c
+++ b/arch/um/os-Linux/process.c
@@ -235,20 +235,13 @@ out:
void init_new_thread_signals(void)
{
- set_handler(SIGSEGV, (__sighandler_t) sig_handler, SA_ONSTACK,
- SIGIO, SIGWINCH, SIGVTALRM, -1);
- set_handler(SIGTRAP, (__sighandler_t) sig_handler, SA_ONSTACK,
- SIGIO, SIGWINCH, SIGVTALRM, -1);
- set_handler(SIGFPE, (__sighandler_t) sig_handler, SA_ONSTACK,
- SIGIO, SIGWINCH, SIGVTALRM, -1);
- set_handler(SIGILL, (__sighandler_t) sig_handler, SA_ONSTACK,
- SIGIO, SIGWINCH, SIGVTALRM, -1);
- set_handler(SIGBUS, (__sighandler_t) sig_handler, SA_ONSTACK,
- SIGIO, SIGWINCH, SIGVTALRM, -1);
+ set_handler(SIGSEGV, (__sighandler_t) sig_handler);
+ set_handler(SIGTRAP, (__sighandler_t) sig_handler);
+ set_handler(SIGFPE, (__sighandler_t) sig_handler);
+ set_handler(SIGILL, (__sighandler_t) sig_handler);
+ set_handler(SIGBUS, (__sighandler_t) sig_handler);
signal(SIGHUP, SIG_IGN);
-
- set_handler(SIGIO, (__sighandler_t) sig_handler,
- SA_ONSTACK | SA_RESTART, SIGIO, SIGWINCH, SIGVTALRM, -1);
+ set_handler(SIGIO, (__sighandler_t) sig_handler);
signal(SIGWINCH, SIG_IGN);
signal(SIGTERM, SIG_DFL);
}
diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c
index 75c3e9c9cabb..f248fb2ab58c 100644
--- a/arch/um/os-Linux/signal.c
+++ b/arch/um/os-Linux/signal.c
@@ -111,8 +111,7 @@ void alarm_handler(int sig, struct sigcontext *sc)
void timer_init(void)
{
- set_handler(SIGVTALRM, (__sighandler_t) alarm_handler,
- SA_ONSTACK | SA_RESTART, SIGIO, SIGWINCH, -1);
+ set_handler(SIGVTALRM, (__sighandler_t) alarm_handler);
}
void set_sigstack(void *sig_stack, int size)
@@ -174,27 +173,28 @@ static void hard_handler(int sig, siginfo_t *info, void *p)
handle_signal(sig, (struct sigcontext *) &uc->uc_mcontext);
}
-void set_handler(int sig, void (*handler)(int), int flags, ...)
+void set_handler(int sig, void (*handler)(int))
{
struct sigaction action;
- va_list ap;
+ int flags = SA_SIGINFO | SA_ONSTACK;
sigset_t sig_mask;
- int mask;
handlers[sig] = (void (*)(int, struct sigcontext *)) handler;
action.sa_sigaction = hard_handler;
+ /* block irq ones */
sigemptyset(&action.sa_mask);
-
- va_start(ap, flags);
- while ((mask = va_arg(ap, int)) != -1)
- sigaddset(&action.sa_mask, mask);
- va_end(ap);
+ sigaddset(&action.sa_mask, SIGVTALRM);
+ sigaddset(&action.sa_mask, SIGIO);
+ sigaddset(&action.sa_mask, SIGWINCH);
if (sig == SIGSEGV)
flags |= SA_NODEFER;
- action.sa_flags = flags | SA_SIGINFO;
+ if (sigismember(&action.sa_mask, sig))
+ flags |= SA_RESTART; /* if it's an irq signal */
+
+ action.sa_flags = flags;
action.sa_restorer = NULL;
if (sigaction(sig, &action, NULL) < 0)
panic("sigaction failed - errno = %d\n", errno);
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
index 20b34dcb0906..31743f1d1195 100644
--- a/arch/um/os-Linux/skas/process.c
+++ b/arch/um/os-Linux/skas/process.c
@@ -659,8 +659,7 @@ int start_idle_thread(void *stack, jmp_buf *switch_buf)
{
int n;
- set_handler(SIGWINCH, (__sighandler_t) sig_handler,
- SA_ONSTACK | SA_RESTART, SIGIO, SIGVTALRM, -1);
+ set_handler(SIGWINCH, (__sighandler_t) sig_handler);
/*
* Can't use UML_SETJMP or UML_LONGJMP here because they save