[PATCH 1/2] signal: add helper to get siginfo without removing from the queue
Andrey Vagin
avagin at openvz.org
Thu Nov 29 11:51:49 EST 2012
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
include/linux/sched.h | 2 ++
kernel/signal.c | 28 ++++++++++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 206bb08..a907854 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2222,6 +2222,8 @@ extern void __flush_signals(struct task_struct *);
extern void ignore_signals(struct task_struct *);
extern void flush_signal_handlers(struct task_struct *, int force_default);
extern int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info);
+extern int peek_signal(struct task_struct *tsk, sigset_t *mask,
+ siginfo_t *info, int offset, bool group);
static inline int dequeue_signal_lock(struct task_struct *tsk, sigset_t *mask, siginfo_t *info)
{
diff --git a/kernel/signal.c b/kernel/signal.c
index ac5f5e7..aa71213 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -536,6 +536,34 @@ unblock_all_signals(void)
spin_unlock_irqrestore(¤t->sighand->siglock, flags);
}
+int peek_signal(struct task_struct *tsk, sigset_t *mask,
+ siginfo_t *info, int offset, bool group)
+{
+ struct sigpending *pending;
+ struct sigqueue *q;
+ int i = 0, ret = 0;
+
+ if (group)
+ pending = &tsk->signal->shared_pending;
+ else
+ pending = &tsk->pending;
+
+ list_for_each_entry(q, &pending->list, list) {
+ if (sigismember(mask, q->info.si_signo))
+ continue;
+
+ if (i == offset) {
+ copy_siginfo(info, &q->info);
+ ret = info->si_signo;
+ break;
+ }
+
+ i++;
+ }
+
+ return ret;
+}
+
static void collect_signal(int sig, struct sigpending *list, siginfo_t *info)
{
struct sigqueue *q, *first = NULL;
--
1.7.11.7
--M9NhX3UHpAaciwkO
Content-Type: text/plain; charset="koi8-r"
Content-Disposition: attachment;
filename="0002-signalfd-add-ability-to-get-signal-without-removing-.patch"
More information about the CRIU
mailing list