From nobody Sun Apr 16 10:48:54 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Pzn3p4drSz456fj; Sun, 16 Apr 2023 10:48:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Pzn3p45T4z3hp9; Sun, 16 Apr 2023 10:48:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681642134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Es71LE1jIvGdBDqPr2+5eBeFruOfGY3u6ClDkXTDOxc=; b=BA5/1YvPpQ/2gy9axZCnA/0EoXK67IWZF4aazAlgpTpFarjcghbL2sXm3Qu3afCY5Vd8GK uadbDr5P/UVbDlqvcFIuRtkJ6EIlfJPMLWvbFP/EjeQWgbVwWnVz3gzmbO2mKvVT+28U+M Yy6Qq3IefRw6N56dqUJMKSGvDrhbPFssvxBJvlL7wyt7kMeIn5RhLjLQSls0NRVdcoTQWj caQNDbFGmxEBxQkDSAbCwZiSibmTprD9tt+qC7wsVEZKjKGIfTvmX3AYf8Lu4Stumt/EJ/ F6qstzOqzNY0mkUoEzFUPNWRH/zwfTvzyqZivUSwc9PORuVGyRqLK4vqgDfJoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681642134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Es71LE1jIvGdBDqPr2+5eBeFruOfGY3u6ClDkXTDOxc=; b=SwInbmLMJ4gonqamGuref+1Sm63A65xbJOr2j3FyIaoSTpBUC85L8nUtzUOgPnnqUnxGmI hlUYKBIUnDl7FIGJsATAk91p214tzX9ij5lJMBFa7K/QDhV5caToPRKqnI2tcONxkrPvOU JsJlC72GK/D48z5yRIJD73vMwEVepIQM8TQIKz0SB64YEqtgngFAojsvmcR4KGD8/EeoI7 9ntfgpYrIwoMxfvtKxjBBrweHc2ofP1HXFysf6p5+0J1eZ6IS81dZtn74CYf9gRorF6aeH RMPIHfeJ/Iz1lAyM1N6BTTYw+fVTp3t69zO6gsU06xSMN/tVtbt3R/f+eqZmww== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681642134; a=rsa-sha256; cv=none; b=Q4KnrGyThaeRqkglXCTpll2mT0uMxa5UBw6iGHJfBe4I2H8jvOw09rugKbdonkhxhzV9Vf BnSx4/ipxly6cNZXcXhHEdF+GTCMWYYXqDlr5wPkK/hywq7XXitVx1aC4VSl66TcnDxqse Lg4laz54ciBfOzphTWodwPksXJeDLLyeJU2ql23zXGvaq8NjU9onvfjjLR233WcOuBWcvM v/j2x1ePfBMjaKeW1KuIiZjRPU5XIiKojHDNE6XC1Z3J5BamRQ15tIHv9HFBFq9pJIiz8Q 52by/exLpvkL1E3+PRARMbJTdpuwb58nF7wdN3PcTEuzhTQl5cy9ryRsjdBIRQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Pzn3p37Pdzkw0; Sun, 16 Apr 2023 10:48:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 33GAms0M004912; Sun, 16 Apr 2023 10:48:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33GAms1X004911; Sun, 16 Apr 2023 10:48:54 GMT (envelope-from git) Date: Sun, 16 Apr 2023 10:48:54 GMT Message-Id: <202304161048.33GAms1X004911@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 77f0e198d913 - main - procctl: add state flags to PROC_REAP_GETPIDS reports List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 77f0e198d9134b6ca2650d3a84d7db2d786ec0c0 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=77f0e198d9134b6ca2650d3a84d7db2d786ec0c0 commit 77f0e198d9134b6ca2650d3a84d7db2d786ec0c0 Author: Val Packett AuthorDate: 2023-04-15 17:59:30 +0000 Commit: Konstantin Belousov CommitDate: 2023-04-16 10:48:20 +0000 procctl: add state flags to PROC_REAP_GETPIDS reports For a process supervisor using the reaper API to track process subtrees, it is very useful to know the state of the processes on the list. Sponsored by: https://www.patreon.com/valpackett Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D39585 --- 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 97509d0fbf06..052fcb37fb9d 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;