From nobody Sun Aug 16 02:46:42 2026 X-Original-To: dev-commits-src-all@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 4hN0jG4wVHz6pGQw for ; Sun, 16 Aug 2026 02:46:42 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hN0jG2FkTz3f8D for ; Sun, 16 Aug 2026 02:46:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1786848402; 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=ANEBNPKIBYgXgcjiEP0mLreVH9zrti30FRAuHobfVI0=; b=yaYmnlR7MOLmyg1nVup/Bg/ktsGip+I8KqCEeM9JY4hWuGgYT3qh9iWfBGQJe15DGjHCv0 RUqpdWgsPsf7GVfqDsk76NxECF3K7ADhzTv7GVsschP1DJCmbhaGKHdFgtpMdQSWpOWYBp oIjiJIADnS4V7KeyHDv2rnDWwH/K4QhUgSORacE6aV3TX10cC2AnnFjWlJsa4d6KKT03lj JTeBA1F/OtgGeEfuTQ2L30Ldv/p96FaPaZFwkyMx297cedSy0fFZnBWkaXtfIMo2JZyviO MjsFPne1RSnykjNPUV3Be94a9x+qTLs/2zmYig8QbHIX2yuj+8oOPEk2VB0yLA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1786848402; a=rsa-sha256; cv=none; b=oL7mQgnaD5/E33+++yGLun9w6BghibZm5zGx4zUG9hU5rLUL485KQWAX0FnNqoG30dCae4 ijWdZJPerGMcSMoTzXiSyYtJLlC9nIyMy+j7pRuZ9BuHG8VzboejH8TzNwtfipYEbJzvx2 axZ7VjcVdWLdwEUhqVTsimhHaR28Mr1uPdw95ixG4zqj6LTcewnrbZSpgwlx9BlC48h5Jo MC5Jb6fQh+2ry5DROcScII3RArCB8mMZ0sAdoKxZhi3cDiVGhh25eiWbqoVTUHctXH8yML wM9FlRq9SW25PAZ04xvt4w2FD2/41LniPRuC8jtE4lPwaVPYIXBCi/WMxgMk+g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1786848402; 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=ANEBNPKIBYgXgcjiEP0mLreVH9zrti30FRAuHobfVI0=; b=CBZP7Vh2A6TEMT7/k7jbcDUBgaeVeHVUrNzQ71TK5mWGOwo83ngMWxdQlyJqAZmjl4j254 hpicIJlnEJWHlUmQyzKmIOa8Tsjgwm+iX8o+hhEWvXZGW45iSdtzsI7TlpJuzki3tjhG4/ AFhu+wOf+HKi53GyS4A2yCV/mNMr857cwad7b8sJkZxFlt2mF8exCf5ft/LzblZAoEfIiw D0jw460TBFNh7EL+F0vqLk07vewYqRqIbjvcqRuS63XjK9KBDAXrHoKZ12y0dnk1wKOqk6 CV1wSfLdKgERgNW/qMt5niYTG6iPViFm4BV+knadbNSVFUfL+WEzloQTvP2nuw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hN0jG16PZz17sh for ; Sun, 16 Aug 2026 02:46:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 4425e by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 16 Aug 2026 02:46:42 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 8c17b933a869 - stable/15 - pdfork.2: document pdopenpid(2) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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/stable/15 X-Git-Reftype: branch X-Git-Commit: 8c17b933a8699037e4e080fe1b36ebbf9a9e32b2 Auto-Submitted: auto-generated Date: Sun, 16 Aug 2026 02:46:42 +0000 Message-Id: <6a812492.4425e.4907de6b@gitrepo.freebsd.org> The branch stable/15 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8c17b933a8699037e4e080fe1b36ebbf9a9e32b2 commit 8c17b933a8699037e4e080fe1b36ebbf9a9e32b2 Author: Konstantin Belousov AuthorDate: 2026-05-21 17:33:43 +0000 Commit: Konstantin Belousov CommitDate: 2026-08-16 02:41:24 +0000 pdfork.2: document pdopenpid(2) (cherry picked from commit 3e8b68c26e2b108dac96517ef8fd26fe7dce5bcd) --- lib/libsys/Makefile.sys | 1 + lib/libsys/pdfork.2 | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/lib/libsys/Makefile.sys b/lib/libsys/Makefile.sys index b17336babfcb..92d6b53d8fde 100644 --- a/lib/libsys/Makefile.sys +++ b/lib/libsys/Makefile.sys @@ -496,6 +496,7 @@ MLINKS+=open.2 openat.2 MLINKS+=pathconf.2 fpathconf.2 MLINKS+=pathconf.2 lpathconf.2 MLINKS+=pdfork.2 pdgetpid.2 \ + pdfork.2 pdopenpid.2 \ pdfork.2 pdkill.2 \ pdfork.2 pdrfork.2 \ pdfork.2 pdwait.2 diff --git a/lib/libsys/pdfork.2 b/lib/libsys/pdfork.2 index 6ebab24ff180..9099edebaa2a 100644 --- a/lib/libsys/pdfork.2 +++ b/lib/libsys/pdfork.2 @@ -36,6 +36,7 @@ .Sh NAME .Nm pdfork , .Nm pdrfork , +.Nm pdopenpid , .Nm pdgetpid , .Nm pdkill , .Nm pdwait @@ -49,6 +50,8 @@ .Ft pid_t .Fn pdrfork "int *fdp" "int pdflags" "int rfflags" .Ft int +.Fn pdopenpid "pid_t pid" "int pdflags" +.Ft int .Fn pdgetpid "int fd" "pid_t *pidp" .Ft int .Fn pdkill "int fd" "int signum" @@ -128,6 +131,28 @@ flags, or .Va RFSPAWN flag are specified. .Pp +.Fn pdopenpid +opens the process descriptor for the process specified by the argument +.Fa pid . +It takes the same flags in the +.Fa pdflags +argument as +.Fn pdfork . +The caller must have permission to debug the target process in order for +.Fn pdopenpid +to succeed. +Zombie processes cannot be opened. +.Pp +There might be more that one file descriptor referencing the process. +But only one caller of +.Fn pdwait +gets the exit status. +After the zombie is reaped, calls to +.Fn pdwait +specifying any file descriptors for the same process fail with the +.Er ESRCH +error. +.Pp .Fn pdgetpid queries the process ID (PID) in the process descriptor .Fa fd . @@ -198,6 +223,7 @@ return a PID, 0 or -1, as .Xr fork 2 does. .Pp +.Fn pdopenpid , .Fn pdgetpid , .Fn pdkill , and @@ -244,6 +270,40 @@ The function is called with reserved bits set in .Fa options . .El +.Pp +The +.Fn pdopenpid +might return the same errors as +.Xr open 2 , +related to the file descriptor allocation problems, as well as the +following specific errors: +.Bl -tag -width Er +.It Bq Er EINVAL +The +.Fa flags +argument has reserved bits set. +.It Bq Er ECAPMODE +.Fn pdopenpid +is called by the process in capability mode. +.It Bq Er EBUSY +The process specified by the +.Fa pid +argument already terminated. +.It Bq Er ESRCH +The process specified by the +.Fa pid +argument does not exist, or the caller does not have enough privileges +to open the process. +.It Bq Er EMFILE +The calling process already reached its limit for open file descriptors. +.Pp +Current implementation installs the opened process descriptor into the +calling process's file descriptors table. +If the descriptor cannot be installed, the process descriptor is closed, +which executes all actions performed by +.Xr close 2 +on it. +.El .Sh SEE ALSO .Xr close 2 , .Xr fork 2 , @@ -268,6 +328,10 @@ and .Fn pdwait system calls first appeared in .Fx 15.1 . +The +.Fn pdopenpid +system call first appeared in +.Fx 16.0 . .Pp Support for process descriptors mode was developed as part of the .Tn TrustedBSD @@ -288,3 +352,7 @@ functions were developed by .An Konstantin Belousov Aq Mt kib@FreeBSD.org with input from .An Alan Somers Aq Mt asomers@FreeBSD.org . +The +.Fn pdopenpid +function was developed by +.An Konstantin Belousov Aq Mt kib@FreeBSD.org .