From 074127b5eb6578e95561061de60f7ecaaa592694 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Thu, 17 Jul 2003 19:27:39 -0700 Subject: [PATCH] [PATCH] CLONE_STOPPED From: Ulrich Drepper CLONE_STOPPED: start a thread in a stopped state. Required for NTPL. --- include/linux/sched.h | 1 + kernel/fork.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 750f2a12cada1..bf740af246c0c 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -52,6 +52,7 @@ struct exec_domain; #define CLONE_DETACHED 0x00400000 /* parent wants no child-exit signal */ #define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */ #define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */ +#define CLONE_STOPPED 0x02000000 /* Start in stopped state */ /* * List of flags we want to share for kernel threads, diff --git a/kernel/fork.c b/kernel/fork.c index 24cba7f5f25de..7c4c94b1a968a 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1076,7 +1076,7 @@ long do_fork(unsigned long clone_flags, init_completion(&vfork); } - if (p->ptrace & PT_PTRACED) { + if ((p->ptrace & PT_PTRACED) || (clone_flags & CLONE_STOPPED)) { /* * We'll start up with an immediate SIGSTOP. */ @@ -1084,7 +1084,9 @@ long do_fork(unsigned long clone_flags, set_tsk_thread_flag(p, TIF_SIGPENDING); } - wake_up_forked_process(p); /* do this last */ + p->state = TASK_STOPPED; + if (!(clone_flags & CLONE_STOPPED)) + wake_up_forked_process(p); /* do this last */ ++total_forks; if (unlikely (trace)) { -- 2.53.0