From ca86b5dce213f52c7538932740f83cafb2c34547 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 7 Nov 2012 15:09:38 -0500 Subject: [PATCH] new helper: get_signal() On success get_signal_to_deliver() fills k_sigaction and siginfo. _All_ users pass it addresses of the local variables sitting in the same function. Then they proceed to pass those addresses pretty much in tandem to a bunch of helper functions; again, all callers of those helpers are passing them such a pair, and one that had been through get_signal_to_deliver() at that. The obvious cleanup: introduce a new type that would contain a pair (struct ksignal) and begin switching to using it. Turns out that it's convenient to store the signal number in the same object. New helper, taking that sucker is a wrapper for get_signal_to_deliver(); takes struct ksignal * and returns bool. On success fills ksignal with the information for signal handler to be invoked. For now it's a macro (to avoid header ordering headache), but eventually it'll be a function in kernel/signal.c, with get_signal_to_deliver() folded into it. Signed-off-by: Al Viro --- include/linux/signal.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/signal.h b/include/linux/signal.h index e28e8d455d6e..7c2744198dba 100644 --- a/include/linux/signal.h +++ b/include/linux/signal.h @@ -279,10 +279,28 @@ struct old_sigaction { }; #endif +struct ksignal { + struct k_sigaction ka; + siginfo_t info; + int sig; +}; + extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie); extern void signal_delivered(int sig, siginfo_t *info, struct k_sigaction *ka, struct pt_regs *regs, int stepping); extern void exit_signals(struct task_struct *tsk); +/* + * Eventually that'll replace get_signal_to_deliver(); macro for now, + * to avoid nastiness with include order. + */ +#define get_signal(ksig) \ +({ \ + struct ksignal *p = (ksig); \ + p->sig = get_signal_to_deliver(&p->info, &p->ka, \ + signal_pt_regs(), NULL);\ + p->sig > 0; \ +}) + extern struct kmem_cache *sighand_cachep; int unhandled_signal(struct task_struct *tsk, int sig);