From nobody Sun Jan 25 17:20:55 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 4dzdjh1lKLz6PpZN for ; Sun, 25 Jan 2026 17:20:56 +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 "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dzdjg44M8z3Vtl for ; Sun, 25 Jan 2026 17:20:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1769361655; 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=WU5h5v0OHPsSMtDIeBnKqWddqWZoxpTo1QUs47YY6dM=; b=rQaneJbM4is32x0xoKz4CFGSUPyM0GnpM7m9i9kwVypJqj5E1rK7RVTVwfkx4cavlO7FV7 db+S6DFTxBHRLaQJnQFetxJGvEHMZ1rQY6C0mKRQSXiMnulgpQOpuabmMIgqfpOu3EB2yf FrEgpbARMnfmY/faIbqPPHo/e4AEJp+1wnGYpILIzhX2ANwSu45nYkFR5eDrJbvxVOQjrH /4+z5sCXU7ykboxOO960huydAEehHhXAp1abLAUcwEn/Q4jIhlGA310xOZLBV69lbuDIdc K56lKxel4N63cRddz//axvlgpipe6LE9dPn8f03wHlS9bpQy6QoDV9A9zyemOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1769361655; 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=WU5h5v0OHPsSMtDIeBnKqWddqWZoxpTo1QUs47YY6dM=; b=b3dBR0GOwLjqivyoZJRi00o1XelgEGFA/5Gzf3LqRW4TzCQ6j+eTSUcrpkH4ckSWhthcNG JmpoWCJr7DM7gENyNwhELK0O/oYHwu3FmSBvMevELt1ENdXsBaNax7EPeXuwN0JN6yqM8G 4IGcQ95Ey7ZFGWZy4TSzvW4UwuGet/uGx7XLtPihX8tWbt11KiIKzJ5tL0bw4MB+7A6YSC HN1BwrMOW/fTgjhn8uhPP7arx7PqwuPYi4Z8Ry4aDqoq5jCS5xDR/xPNvunyKogjl8OLDn eXrco0w9guiL1lZW0RNXaJfnvoNPiXdCyCwWcgeiUj9rC/1ib6J0D6QIP15pZQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1769361655; a=rsa-sha256; cv=none; b=V1uCxINpkatpztEZY02BBMoKpVt2jL0L7dFdatCVeGfbYzzY0E2fmUD6d/UAbcarLwuIcY TrMypJM+rilaK7SYmXy1Apff1moMw4yR9Y3RhSv6l3kW2CAPlylTrLtoKidZDqbUx/oBB7 PB3Uz4a5Hl4KtwzkymPUBayWnbiFjZ/0iY5+FRi0lrnFPmWzfxo60z9L9ZiHSaBWuZHDtD dDLs+zp1Gn62aG0EvnZg9JkzJ17HeAwdkL4F5E8IA7sx+cZnJmnyLEovkBAYXPfNILxoKL o5iOJZnxDEtFjt/GGb+9llj6H6xqYAf1IxuLAU/OaNoQJRTYE7mLGUuEKKQiYA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dzdjg3L4dzl4Q for ; Sun, 25 Jan 2026 17:20:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3c068 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 25 Jan 2026 17:20:55 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 3f0aea09689f - main - libc: add posix_spawnattr_{get,set}execfd_np(3) 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 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: 3f0aea09689f6c10740de78011469355208a19a5 Auto-Submitted: auto-generated Date: Sun, 25 Jan 2026 17:20:55 +0000 Message-Id: <697650f7.3c068.18b593cd@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=3f0aea09689f6c10740de78011469355208a19a5 commit 3f0aea09689f6c10740de78011469355208a19a5 Author: Konstantin Belousov AuthorDate: 2026-01-24 22:06:36 +0000 Commit: Konstantin Belousov CommitDate: 2026-01-25 17:19:53 +0000 libc: add posix_spawnattr_{get,set}execfd_np(3) If execfd is set, the fexecve(2) is used by posix_spawn() instead of the provided path. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D54862 --- include/spawn.h | 7 +++++++ lib/libc/gen/Symbol.map | 5 +++++ lib/libc/gen/posix_spawn.c | 22 +++++++++++++++++++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/include/spawn.h b/include/spawn.h index a93315930954..a8f40e49dce0 100644 --- a/include/spawn.h +++ b/include/spawn.h @@ -123,6 +123,13 @@ int posix_spawnattr_setsigdefault(posix_spawnattr_t * __restrict, const sigset_t * __restrict); int posix_spawnattr_setsigmask(posix_spawnattr_t * __restrict, const sigset_t * __restrict); + +#if __BSD_VISIBLE +int posix_spawnattr_setexecfd_np(posix_spawnattr_t * __restrict, int); +int posix_spawnattr_getexecfd_np(const posix_spawnattr_t * __restrict, + int * __restrict); +#endif + __END_DECLS #endif /* !_SPAWN_H_ */ diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map index 494b65bc5cc1..19170768ef7c 100644 --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -474,6 +474,11 @@ FBSD_1.8 { str2sig; }; +FBSD_1.9 { + posix_spawnattr_getexecfd_np; + posix_spawnattr_setexecfd_np; +}; + FBSDprivate_1.0 { /* needed by thread libraries */ __thr_jtable; diff --git a/lib/libc/gen/posix_spawn.c b/lib/libc/gen/posix_spawn.c index a5b732696b8c..fc327e15bbf0 100644 --- a/lib/libc/gen/posix_spawn.c +++ b/lib/libc/gen/posix_spawn.c @@ -50,6 +50,7 @@ struct __posix_spawnattr { int sa_schedpolicy; sigset_t sa_sigdefault; sigset_t sa_sigmask; + int sa_execfd; }; struct __posix_spawn_file_actions { @@ -260,7 +261,9 @@ _posix_spawn_thr(void *data) _exit(127); } envp = psa->envp != NULL ? psa->envp : environ; - if (psa->use_env_path) + if (psa->sa != NULL && (*(psa->sa))->sa_execfd != -1) + fexecve((*(psa->sa))->sa_execfd, psa->argv, envp); + else if (psa->use_env_path) __libc_execvpe(psa->path, psa->argv, envp); else _execve(psa->path, psa->argv, envp); @@ -578,6 +581,7 @@ posix_spawnattr_init(posix_spawnattr_t *ret) sa = calloc(1, sizeof(struct __posix_spawnattr)); if (sa == NULL) return (errno); + sa->sa_execfd = -1; /* Set defaults as specified by POSIX, cleared above */ *ret = sa; @@ -639,6 +643,14 @@ posix_spawnattr_getsigmask(const posix_spawnattr_t * __restrict sa, return (0); } +int +posix_spawnattr_getexecfd_np(const posix_spawnattr_t * __restrict sa, + int * __restrict fdp) +{ + *fdp = (*sa)->sa_execfd; + return (0); +} + int posix_spawnattr_setflags(posix_spawnattr_t *sa, short flags) { @@ -688,3 +700,11 @@ posix_spawnattr_setsigmask(posix_spawnattr_t * __restrict sa, (*sa)->sa_sigmask = *sigmask; return (0); } + +int +posix_spawnattr_setexecfd_np(posix_spawnattr_t * __restrict sa, + int execfd) +{ + (*sa)->sa_execfd = execfd; + return (0); +}