From nobody Sun Aug 16 02:46:50 2026 X-Original-To: dev-commits-src-branches@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 4hN0jR4XP0z6pHFW for ; Sun, 16 Aug 2026 02:46:51 +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 4hN0jR03nHz3fFy for ; Sun, 16 Aug 2026 02:46:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1786848411; 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=xRUJeB4qUMYAvYuneeZgxxgJRFiqiQM7/6xjMXeQTrs=; b=EA0iTM711cnGRe5CpSig4phE2J7wlgm16oIBlelCm3OqlGgzZmPSOeO6MbOdKx35w38DFc K1qWqHxF6MZ1Sf4iNvXMkDhQryjxl757zYo9ctNcGKGC0gJQUAN9ylwkJWlgV9CKBhQ0GA 794l8PkpUSowvWr7vRFDDaTm32gT1FDThKLq2NDaW4A6/Y9yM1mEIMYnROUfNX+63aid7L wcgyX+Ieb2Ory215PwqNENjPHtre7DH9vpbKw0GrN8/ahEKFBlVb603qHS8GDQi8zR+qHE ygKAqro36IvG1ENuhDZQ35NFeK+wo9+cuzMhRbEVzxUkDBk4WO5cV6YR4/EWtg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1786848411; a=rsa-sha256; cv=none; b=p7rm7fKscPzJyF75k2dz+pnVtV4ZBd+duIXiE/E8G5rK4POCFMI7AQnCeKwJqaF7qiq3hF DrmQDjUXS+Spq0VOYWyG6HSUp+oYxkRwkO/RJTyMFRNSxXfheAwicHstqspBVwji1I3NG9 pp1rdXjZq93lIV64n3trGaVZGLdKDQ8rW3i4ZqADVkmkRIe5s/J7T8h2OE0TO4LWJM3xlq Zd3XkjT6NPbkYevo7Y+DQrc2yOj2V0Ha1t7+PZKl7aDUbpYnt2mKWi9qWuAieuX5P9yl53 B8O5+hgZuAeUvS9DmtI4rB2sBlMwfrDnvht0E7bqu93X/a3lnbM1c2NKwxIcdg== 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=1786848411; 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=xRUJeB4qUMYAvYuneeZgxxgJRFiqiQM7/6xjMXeQTrs=; b=OKz0Hjsker2ce9p3HL9qll4VNXT0NOADjjVjVLqPnCWTUjrwr1BT63xUmafimuSoK8dJ3i KxpZgQcj4wRUGIZXy0+SilIfHUNw+Rmn7mpdAKQW6Fy+OgBCOWmIi6ANvbcYYOrtodkWf8 0NPT0NOVkuDIC/6MslnMhWfnrHjuDub1HvXmvXBySvnE4+ulgko8NaKTkHIDaF+BKfrBw0 Ibms/eesXeP7MA8pzBzQJzbTrSV8pCaBd7J5MjKARwP7POk3qr142LuEVPLgP7mvw0Bojg fcXevotpRHuh7xUkZgY93fNVZhIwPawxJLgWgucwKcL2APjNK/qNH0UOKixDGQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hN0jQ6BkNz17xk for ; Sun, 16 Aug 2026 02:46:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 446df by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 16 Aug 2026 02:46:50 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 55fdf7561cc4 - stable/15 - pdfork.2: document pddupfd() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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: 55fdf7561cc4d7048a46264b115987c4ac03baab Auto-Submitted: auto-generated Date: Sun, 16 Aug 2026 02:46:50 +0000 Message-Id: <6a81249a.446df.7d13ed16@gitrepo.freebsd.org> The branch stable/15 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=55fdf7561cc4d7048a46264b115987c4ac03baab commit 55fdf7561cc4d7048a46264b115987c4ac03baab Author: Konstantin Belousov AuthorDate: 2026-05-22 10:09:01 +0000 Commit: Konstantin Belousov CommitDate: 2026-08-16 02:41:27 +0000 pdfork.2: document pddupfd() (cherry picked from commit c20558e5c9dadfdddc879ee50a65d14beb4992b9) --- 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 92d6b53d8fde..afe24345bc5d 100644 --- a/lib/libsys/Makefile.sys +++ b/lib/libsys/Makefile.sys @@ -499,7 +499,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 .