From nobody Tue Jul 7 23:28:25 2026 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 4gvy8T5tgWz6kCKy for ; Tue, 07 Jul 2026 23:28:25 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gvy8T3NSSz3FWx for ; Tue, 07 Jul 2026 23:28:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1783466905; 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=PomDAolh7lIcX0Osltsv45YCOj/13egrq1zbk/bpO5w=; b=hzWVr1FN4ib9nqMbIs/1cTaA6O8A5qF6QpbZiq/NtWCa4vg4KSZaBn/0TNjG0wcX8aV5XQ AuzxHJfr4V6ZzU1R82cOm8AynhNT03Ma5m9OW4LOjOaQvElu7VW6mwovnRsnM2khkkufwk wNCwTS6v/vp2Ksn+7ukvGrK4C6kwMkCQqvNGnbIqRuUroelIHAf1eDkLXws0GGMwqNd1Ys OqELvzZ84AaIsltMPjyGKgmah7JkqHpEPbLKUT3/rySNI0sJcxsEOty+rk68Gzcts9gZqv gQ2pWHFSjntKJIrxxDLaqFD2HicUhwn4Ib3X8tEzaTD0d2Q5CN8mR7s1pcs8ng== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1783466905; a=rsa-sha256; cv=none; b=H8CszDfbbQHnUL/oWMor9RhaE7HbyKoAQmtsR1715jeCE3JqRWK/lNzYD+DGxUhoFJ/nvB jwL/OK8sMEZo7nFJnHV5+OpKKgdhjBAalrrwlnb3mSinzgveBVy+epGMcGptqQHR4epJFV jFZVDdN7lO/qIHL5Du36zerGRK51Qpoc4H6V1mPGx6Ny4DgcjYmZ9Jsa3PeAEDWWgJs8+T /pDzEVWUZw/LQgVSZMKu+CLEDRas0sgo10TKvF7Gsl3M/u48IKAX6bOie6Ql7xa5i/EbSL ezXwvZQve1wtbq44L8u7Q8+vBQQEXQ8ClYcv23JdlTkKo1uflpHaIMoo17FtWg== 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=1783466905; 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=PomDAolh7lIcX0Osltsv45YCOj/13egrq1zbk/bpO5w=; b=ryZSvuS3SJG19CvM7V/J2c3DJyv13H+YXJuaPiHyAYd0Y9KTL6KocaOai7xalGLE2MVYnq m9Wr5gdHuO3Xp8ahzNIJGGjAOrc6dRgyiH1V80dTc4TTFz9ZESJ6ykOp2eYYikL3TTjLWX aUt02WdIxAOmXEoZAzAmPH/qWbI4JYewckkoHyU9sptD0y97zwKm3E39QC9Fu/ksO8FTcK lWb/sTcDSFX2u1T0AbM7jeELD8lW66GlYCK350j8VMfTNwa48MfPaZ/paq4Ti0xO7x3jHH ILj8eM+SIUPk7D9UkEvu5t4nR3qHzC714YmVgYB2WB/ZpTI7VAmOFn6n1HO1Mw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gvy8T2BWRzwlX for ; Tue, 07 Jul 2026 23:28:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 27665 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 07 Jul 2026 23:28:25 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: c20558e5c9da - main - pdfork.2: document pddupfd() 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: c20558e5c9dadfdddc879ee50a65d14beb4992b9 Auto-Submitted: auto-generated Date: Tue, 07 Jul 2026 23:28:25 +0000 Message-Id: <6a4d8b99.27665.176ec2bf@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c20558e5c9dadfdddc879ee50a65d14beb4992b9 commit c20558e5c9dadfdddc879ee50a65d14beb4992b9 Author: Konstantin Belousov AuthorDate: 2026-05-22 10:09:01 +0000 Commit: Konstantin Belousov CommitDate: 2026-07-07 22:03:53 +0000 pdfork.2: document pddupfd() Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D57163 --- lib/libsys/Makefile.sys | 3 ++- lib/libsys/pdfork.2 | 57 +++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/lib/libsys/Makefile.sys b/lib/libsys/Makefile.sys index c362258b89f4..5924abb43a39 100644 --- a/lib/libsys/Makefile.sys +++ b/lib/libsys/Makefile.sys @@ -500,7 +500,8 @@ MLINKS+=pdfork.2 pdgetpid.2 \ pdfork.2 pdopenpid.2 \ pdfork.2 pdkill.2 \ pdfork.2 pdrfork.2 \ - pdfork.2 pdwait.2 + pdfork.2 pdwait.2 \ + pdfork.2 pddupfd.2 MLINKS+=pipe.2 pipe2.2 MLINKS+=poll.2 ppoll.2 MLINKS+=rctl_add_rule.2 rctl_get_limits.2 \ diff --git a/lib/libsys/pdfork.2 b/lib/libsys/pdfork.2 index 18dff970be1f..a6bf8534003d 100644 --- a/lib/libsys/pdfork.2 +++ b/lib/libsys/pdfork.2 @@ -39,7 +39,8 @@ .Nm pdopenpid , .Nm pdgetpid , .Nm pdkill , -.Nm pdwait +.Nm pdwait , +.Nm pddupfd .Nd System calls to manage process descriptors .Sh LIBRARY .Lb libc @@ -63,6 +64,8 @@ .Fa "struct __wrusage *wrusage" .Fa "struct __siginfo *info" .Fc +.Ft int +.Fn pddupfd "int fd" "int remotefd" "int flags" .Sh DESCRIPTION Process descriptors are special file descriptors that represent processes, and are created using @@ -176,6 +179,23 @@ See the description of the .Xr wait6 system call for the behavior specification. .Pp +The +.Fn pddupfd +allows the caller to duplicate a file descriptor across the process +boundaries. +The function returns the new file descriptor that points to the same file +as the file descriptor +.Fa remotefd +in the process specified by the +.Fa fd +process descriptor. +The returned file descriptor has the +.Va O_CLOEXEC +flag set. +The +.Fa flags +argument is reserved and must be zero. +.Pp The following system calls also have effects specific to process descriptors: .Pp .Xr fstat 2 @@ -228,8 +248,9 @@ does. .Fn pdopenpid , .Fn pdgetpid , .Fn pdkill , +.Fn pdwait , and -.Fn pdwait +.Fn pddupfd return 0 on success and -1 on failure. .Sh ERRORS These functions may return the same error numbers as their PID-based equivalents @@ -306,6 +327,30 @@ which executes all actions performed by .Xr close 2 on it. .El +.Pp +The +.Fn pddupfd +returns the following errors: +.Bl -tag -width Er +.It Bq Er EINVAL +The +.Fa flags +argument is not zero. +.It Bq Er ESRCH +The process specified by the file descriptor +.Fa fd +exited. +.It Bq Er EBADF +The file descriptor +.Fa fd +is not a process file descriptor. +.It Bq Er EBADF +The file descriptor +.Fa remotefd +is not a valid file descriptor in the specified process. +.It Bq Er ENOENT +The specified process does not have a file descriptor table. +.El .Sh SEE ALSO .Xr close 2 , .Xr fork 2 , @@ -332,7 +377,9 @@ system calls first appeared in .Fx 15.1 . The .Fn pdopenpid -system call first appeared in +and +.Fn pddupfd +system calls first appeared in .Fx 16.0 . .Pp Support for process descriptors mode was developed as part of the @@ -356,5 +403,7 @@ with input from .An Alan Somers Aq Mt asomers@FreeBSD.org . The .Fn pdopenpid -function was developed by +and +.Fn pddupfd +functions were developed by .An Konstantin Belousov Aq Mt kib@FreeBSD.org .