The branch stable/13 has been updated by kib:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=c34e421db38321678ee3298d3a4c209130e7910c

commit c34e421db38321678ee3298d3a4c209130e7910c
Author:     Val Packett <[email protected]>
AuthorDate: 2023-04-15 17:59:30 +0000
Commit:     Konstantin Belousov <[email protected]>
CommitDate: 2023-04-23 06:23:31 +0000

    procctl: add state flags to PROC_REAP_GETPIDS reports
    
    (cherry picked from commit 77f0e198d9134b6ca2650d3a84d7db2d786ec0c0)
---
 lib/libc/sys/procctl.2  | 10 ++++++++--
 sys/kern/kern_procctl.c |  6 ++++++
 sys/sys/procctl.h       |  3 +++
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/lib/libc/sys/procctl.2 b/lib/libc/sys/procctl.2
index 02979e934451..89e4f2d33c64 100644
--- a/lib/libc/sys/procctl.2
+++ b/lib/libc/sys/procctl.2
@@ -29,7 +29,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd September 2, 2021
+.Dd April 15, 2023
 .Dt PROCCTL 2
 .Os
 .Sh NAME
@@ -302,7 +302,7 @@ of the process.
 The
 .Fa pi_flags
 field returns the following flags, further describing the descendant:
-.Bl -tag -width REAPER_PIDINFO_REAPER
+.Bl -tag -width REAPER_PIDINFO_EXITING
 .It Dv REAPER_PIDINFO_VALID
 Set to indicate that the
 .Vt procctl_reaper_pidinfo
@@ -320,6 +320,12 @@ field identifies the direct child of the reaper.
 .It Dv REAPER_PIDINFO_REAPER
 The reported process is itself a reaper.
 The descendants of the subordinate reaper are not reported.
+.It Dv REAPER_PIDINFO_ZOMBIE
+The reported process is in the zombie state, ready to be reaped.
+.It Dv REAPER_PIDINFO_STOPPED
+The reported process is stopped by a SIGSTOP/SIGTSTP signal.
+.It Dv REAPER_PIDINFO_EXITING
+The reported process is in the process of exiting (but not yet a zombie).
 .El
 .It Dv PROC_REAP_KILL
 Request to deliver a signal to some subset of the descendants of the reaper.
diff --git a/sys/kern/kern_procctl.c b/sys/kern/kern_procctl.c
index 9d48b04dde48..a4f675c2938e 100644
--- a/sys/kern/kern_procctl.c
+++ b/sys/kern/kern_procctl.c
@@ -234,6 +234,12 @@ reap_getpids(struct thread *td, struct proc *p, void *data)
                        pip->pi_flags |= REAPER_PIDINFO_CHILD;
                if ((p2->p_treeflag & P_TREE_REAPER) != 0)
                        pip->pi_flags |= REAPER_PIDINFO_REAPER;
+               if ((p2->p_flag & P_STOPPED) != 0)
+                       pip->pi_flags |= REAPER_PIDINFO_STOPPED;
+               if (p2->p_state == PRS_ZOMBIE)
+                       pip->pi_flags |= REAPER_PIDINFO_ZOMBIE;
+               else if ((p2->p_flag & P_WEXIT) != 0)
+                       pip->pi_flags |= REAPER_PIDINFO_EXITING;
                i++;
        }
        sx_sunlock(&proctree_lock);
diff --git a/sys/sys/procctl.h b/sys/sys/procctl.h
index 0fcb62e94bb9..2d4b19325bbf 100644
--- a/sys/sys/procctl.h
+++ b/sys/sys/procctl.h
@@ -102,6 +102,9 @@ struct procctl_reaper_pidinfo {
 #define        REAPER_PIDINFO_VALID    0x00000001
 #define        REAPER_PIDINFO_CHILD    0x00000002
 #define        REAPER_PIDINFO_REAPER   0x00000004
+#define        REAPER_PIDINFO_ZOMBIE   0x00000008
+#define        REAPER_PIDINFO_STOPPED  0x00000010
+#define        REAPER_PIDINFO_EXITING  0x00000020
 
 struct procctl_reaper_pids {
        u_int   rp_count;

Reply via email to