git: 6c27e0b8e19e - stable/12 - ptrace: restructure comments around reparenting on PT_DETACH
Konstantin Belousov
kib at FreeBSD.org
Sat May 1 00:39:04 UTC 2021
The branch stable/12 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=6c27e0b8e19e2665b8c7049f67a43a63dde6fcf4
commit 6c27e0b8e19e2665b8c7049f67a43a63dde6fcf4
Author: Konstantin Belousov <kib at FreeBSD.org>
AuthorDate: 2021-04-11 09:06:21 +0000
Commit: Konstantin Belousov <kib at FreeBSD.org>
CommitDate: 2021-05-01 00:38:29 +0000
ptrace: restructure comments around reparenting on PT_DETACH
(cherry picked from commit a091c353235e0ee97d2531e80d9d64e1648350f4)
---
sys/kern/sys_process.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c
index c61a77cd7584..cac4916c2460 100644
--- a/sys/kern/sys_process.c
+++ b/sys/kern/sys_process.c
@@ -1160,14 +1160,16 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
break;
case PT_DETACH:
/*
- * Reset the process parent.
- *
- * NB: This clears P_TRACED before reparenting
+ * Clear P_TRACED before reparenting
* a detached process back to its original
* parent. Otherwise the debugee will be set
* as an orphan of the debugger.
*/
p->p_flag &= ~(P_TRACED | P_WAITED);
+
+ /*
+ * Reset the process parent.
+ */
if (p->p_oppid != p->p_pptr->p_pid) {
PROC_LOCK(p->p_pptr);
sigqueue_take(p->p_ksi);
@@ -1180,9 +1182,11 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
CTR3(KTR_PTRACE,
"PT_DETACH: pid %d reparented to pid %d, sig %d",
p->p_pid, pp->p_pid, data);
- } else
+ } else {
CTR2(KTR_PTRACE, "PT_DETACH: pid %d, sig %d",
p->p_pid, data);
+ }
+
p->p_ptevents = 0;
FOREACH_THREAD_IN_PROC(p, td3) {
if ((td3->td_dbgflags & TDB_FSTP) != 0) {
More information about the dev-commits-src-all
mailing list