lkml.org 
[lkml]   [2011]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 07/11] ptrace: add JOBCTL_TRAPPED
Date
For to-be-added end of group stop notification, ptracer needs to tell
whether tracee is in group stop or INTERRUPT trap. Add JOBCTL_TRAPPED
flag which is set when tracee commits to group stop or INTERRUPT trap
in ptrace_stop() and cleared when leaving ptrace_stop().

The flag isn't yet used and doesn't cause any behavior difference.

Signed-off-by: Tejun Heo <tj@kernel.org>
---
include/linux/sched.h | 1 +
kernel/signal.c | 9 +++++++++
2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 221ab51..9d92444 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1787,6 +1787,7 @@ extern void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *
#define JOBCTL_TRAP_SEIZE (1 << 19) /* trap for seize */
#define JOBCTL_TRAP_INTERRUPT (1 << 20) /* trap for interrupt */
#define JOBCTL_TRAPPING (1 << 22) /* switching to TRACED */
+#define JOBCTL_TRAPPED (1 << 23) /* trapped for group stop */

#define JOBCTL_TRAP_MASK (JOBCTL_TRAP_SEIZE | JOBCTL_TRAP_INTERRUPT)
#define JOBCTL_PENDING_MASK (JOBCTL_STOP_PENDING | JOBCTL_TRAP_MASK)
diff --git a/kernel/signal.c b/kernel/signal.c
index 9705f5d..208f061 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1764,6 +1764,14 @@ static void ptrace_stop(int exit_code, int why, int clear_code, siginfo_t *info)
if (is_intr)
current->jobctl &= ~JOBCTL_TRAP_INTERRUPT;

+ /*
+ * Traps for both actual group stop and INTERRUPT are considered
+ * trapped for job control and have TRAPPED set. This enables
+ * end-of-group-stop retrapping of INTERRUPTed tracees.
+ */
+ if (why == CLD_STOPPED || is_intr)
+ current->jobctl |= JOBCTL_TRAPPED;
+
spin_unlock_irq(&current->sighand->siglock);
read_lock(&tasklist_lock);
if (may_ptrace_stop()) {
@@ -1824,6 +1832,7 @@ static void ptrace_stop(int exit_code, int why, int clear_code, siginfo_t *info)
* any signal-sending on another CPU that wants to examine it.
*/
spin_lock_irq(&current->sighand->siglock);
+ current->jobctl &= ~JOBCTL_TRAPPED;
current->last_siginfo = NULL;

/*
--
1.7.1


\
 
 \ /
  Last update: 2011-05-08 17:53    [W:0.950 / U:0.708 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site