aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/signalfd.h
diff options
context:
space:
mode:
authorDavide Libenzi <davidel@xmailserver.org>2007-09-20 15:40:16 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-09-20 16:19:59 -0400
commitb8fceee17a310f189188599a8fa5e9beaff57eb0 (patch)
tree21308319be2579059a4d4d7db680a73334659f82 /include/linux/signalfd.h
parent9db619e66503494e41159de3c76fafabe80d016b (diff)
signalfd simplification
This simplifies signalfd code, by avoiding it to remain attached to the sighand during its lifetime. In this way, the signalfd remain attached to the sighand only during poll(2) (and select and epoll) and read(2). This also allows to remove all the custom "tsk == current" checks in kernel/signal.c, since dequeue_signal() will only be called by "current". I think this is also what Ben was suggesting time ago. The external effect of this, is that a thread can extract only its own private signals and the group ones. I think this is an acceptable behaviour, in that those are the signals the thread would be able to fetch w/out signalfd. Signed-off-by: Davide Libenzi <davidel@xmailserver.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/signalfd.h')
-rw-r--r--include/linux/signalfd.h40
1 files changed, 4 insertions, 36 deletions
diff --git a/include/linux/signalfd.h b/include/linux/signalfd.h
index 510429495690..4c9ff0910ae0 100644
--- a/include/linux/signalfd.h
+++ b/include/linux/signalfd.h
@@ -45,49 +45,17 @@ struct signalfd_siginfo {
45#ifdef CONFIG_SIGNALFD 45#ifdef CONFIG_SIGNALFD
46 46
47/* 47/*
48 * Deliver the signal to listening signalfd. This must be called 48 * Deliver the signal to listening signalfd.
49 * with the sighand lock held. Same are the following that end up
50 * calling signalfd_deliver().
51 */
52void signalfd_deliver(struct task_struct *tsk, int sig);
53
54/*
55 * No need to fall inside signalfd_deliver() if no signal listeners
56 * are available.
57 */ 49 */
58static inline void signalfd_notify(struct task_struct *tsk, int sig) 50static inline void signalfd_notify(struct task_struct *tsk, int sig)
59{ 51{
60 if (unlikely(!list_empty(&tsk->sighand->signalfd_list))) 52 if (unlikely(waitqueue_active(&tsk->sighand->signalfd_wqh)))
61 signalfd_deliver(tsk, sig); 53 wake_up(&tsk->sighand->signalfd_wqh);
62}
63
64/*
65 * The signal -1 is used to notify the signalfd that the sighand
66 * is on its way to be detached.
67 */
68static inline void signalfd_detach_locked(struct task_struct *tsk)
69{
70 if (unlikely(!list_empty(&tsk->sighand->signalfd_list)))
71 signalfd_deliver(tsk, -1);
72}
73
74static inline void signalfd_detach(struct task_struct *tsk)
75{
76 struct sighand_struct *sighand = tsk->sighand;
77
78 if (unlikely(!list_empty(&sighand->signalfd_list))) {
79 spin_lock_irq(&sighand->siglock);
80 signalfd_deliver(tsk, -1);
81 spin_unlock_irq(&sighand->siglock);
82 }
83} 54}
84 55
85#else /* CONFIG_SIGNALFD */ 56#else /* CONFIG_SIGNALFD */
86 57
87#define signalfd_deliver(t, s) do { } while (0) 58static inline void signalfd_notify(struct task_struct *tsk, int sig) { }
88#define signalfd_notify(t, s) do { } while (0)
89#define signalfd_detach_locked(t) do { } while (0)
90#define signalfd_detach(t) do { } while (0)
91 59
92#endif /* CONFIG_SIGNALFD */ 60#endif /* CONFIG_SIGNALFD */
93 61