From nobody Tue Nov 30 02:16:41 2021 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 8207D18B19FF; Tue, 30 Nov 2021 02:16: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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J35SV0DqYz4VpF; Tue, 30 Nov 2021 02:16:41 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 A5B055FFA; Tue, 30 Nov 2021 02:16:41 +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 1AU2GfBx008256; Tue, 30 Nov 2021 02:16:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1AU2Gf9F008255; Tue, 30 Nov 2021 02:16:41 GMT (envelope-from git) Date: Tue, 30 Nov 2021 02:16:41 GMT Message-Id: <202111300216.1AU2Gf9F008255@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: 78963d796d5c - main - Document posix_spawn_file_actions_addclosefrom_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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: 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: 78963d796d5cd8b4f6f0e810eaae7a5f02706b02 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638238602; 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=0lE8gsOKK7O4J9RkrQmxxkqAea7k2r0/jxOfbdN/VYo=; b=SeqhcEkhQyfQI0W0YQXx0X6Hsy64bqqXaaKk5QzymtuGiBmqTVIR6FusguXgHcOGiAY9Xn iuwLK8ZpsNwJJaibjfYfgP4PDu6naftTimlCnZoiC/ebTgIJHjOlCPrDiUwCH4UCpZX1EQ 1/y1jGtvE9GnDNkUnjByGO2FG+vVhB6OPlIuxEX7LYuF6V/mNO3qn6FCoBNklpcuv6zU3r Poqdjyv5BP1rWOGCCIKbzUq+yCj1l0Zm3/W7ifMHguMVPAGtjpIm2ehxCYB/7KU5daKCZo C0wAzf8+FRSTCt/sAeqZzN6D2ZAO/67HqT/uaivGz0M36pJ73lcLlAmNvhhccA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638238602; a=rsa-sha256; cv=none; b=jaPnU/XEV9QMNgVUPjtO/DHEGs72w8mpC2v0qibqXZnbG5XUhMzDiiRPc9WVIx6Y1cQ3Df 2+u/3vrGbhQK0NAXfnsCHgIM8pdzFcpGh+lDxhqb/K0MfzFjnZEqWUpCXHIlg9dctIDUa9 xzxzVAfPI9oQgVwZMB+9SFUCjMeuL8ijC6fz3xBJMSfA8MQbxM8TTZPwJdQOUs5qoSxS8Q XVaphdePy9h1xlyCSoPkwov5L1lwHyKftlHKm3scV1ZsHsHayoOQ/kZBC49jOHS8IFauL5 6Uw3e4ejoHg+eumiE+h14B6yVLeKn7WvCd3wljel2KyRtagPDjQLJtl+M61Q3g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=78963d796d5cd8b4f6f0e810eaae7a5f02706b02 commit 78963d796d5cd8b4f6f0e810eaae7a5f02706b02 Author: Konstantin Belousov AuthorDate: 2021-11-28 00:23:55 +0000 Commit: Konstantin Belousov CommitDate: 2021-11-30 01:43:54 +0000 Document posix_spawn_file_actions_addclosefrom_np(3) Reviewed by: kevans, ngie (previous version) Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D33143 --- lib/libc/gen/Makefile.inc | 1 + lib/libc/gen/posix_spawn.3 | 6 ++++++ lib/libc/gen/posix_spawn_file_actions_addopen.3 | 26 ++++++++++++++++++++----- lib/libc/gen/posix_spawn_file_actions_init.3 | 1 + 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index 0b53a275e861..6a9e284b5860 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -463,6 +463,7 @@ MLINKS+=modf.3 modff.3 \ MLINKS+=popen.3 pclose.3 MLINKS+=posix_spawn.3 posix_spawnp.3 \ posix_spawn_file_actions_addopen.3 posix_spawn_file_actions_addclose.3 \ + posix_spawn_file_actions_addopen.3 posix_spawn_file_actions_addclosefrom_np.3 \ posix_spawn_file_actions_addopen.3 posix_spawn_file_actions_adddup2.3 \ posix_spawn_file_actions_addopen.3 posix_spawn_file_actions_addchdir_np.3 \ posix_spawn_file_actions_addopen.3 posix_spawn_file_actions_addfchdir_np.3 \ diff --git a/lib/libc/gen/posix_spawn.3 b/lib/libc/gen/posix_spawn.3 index 848733a41a7d..f7d54903dcb6 100644 --- a/lib/libc/gen/posix_spawn.3 +++ b/lib/libc/gen/posix_spawn.3 @@ -422,6 +422,11 @@ in addition to those described by This implementation ignores any errors from .Fn close , including trying to close a descriptor that is not open. +The ignore extends to any errors from individual file descriptors +.Fn close +executed as part of the +.Fn closefrom +action. .El .Sh SEE ALSO .Xr close 2 , @@ -434,6 +439,7 @@ including trying to close a descriptor that is not open. .Xr setpgid 2 , .Xr vfork 2 , .Xr posix_spawn_file_actions_addclose 3 , +.Xr posix_spawn_file_actions_addclosefrom_np 3 , .Xr posix_spawn_file_actions_adddup2 3 , .Xr posix_spawn_file_actions_addopen 3 , .Xr posix_spawn_file_actions_addchdir_np 3 , diff --git a/lib/libc/gen/posix_spawn_file_actions_addopen.3 b/lib/libc/gen/posix_spawn_file_actions_addopen.3 index b364e92c18f8..0782e15b3126 100644 --- a/lib/libc/gen/posix_spawn_file_actions_addopen.3 +++ b/lib/libc/gen/posix_spawn_file_actions_addopen.3 @@ -41,9 +41,10 @@ .Nm posix_spawn_file_actions_addopen , .Nm posix_spawn_file_actions_adddup2 , .Nm posix_spawn_file_actions_addclose , +.Nm posix_spawn_file_actions_addclosefrom_np , .Nm posix_spawn_file_actions_addchdir_np , .Nm posix_spawn_file_actions_addfchdir_np -.Nd "add open, dup2, close, or chdir/fchdir actions to spawn file actions object" +.Nd "add open, dup2, close, closefrom, or chdir/fchdir actions to spawn file actions object" .Sh LIBRARY .Lb libc .Sh SYNOPSIS @@ -68,6 +69,11 @@ .Fa "int fildes" .Fc .Ft int +.Fo posix_spawn_file_actions_addclosefrom_np +.Fa "posix_spawn_file_actions_t * file_actions" +.Fa "int from" +.Fc +.Ft int .Fo posix_spawn_file_actions_addchdir_np .Fa "posix_spawn_file_actions_t *restrict file_actions" .Fa "const char *restrict path" @@ -177,6 +183,14 @@ had been called) when a new process is spawned using this file actions object. .Pp The +.Fn posix_spawn_file_actions_addclosefrom_np +function adds a close action to close all file descriptors numerically +equal or greater then the argument +.Fa from . +For each open file descriptor, logically the close action is performed, +and any possible errors encountered are ignored. +.Pp +The .Fn posix_spawn_file_actions_addchdir_np and .Fn posix_spawn_file_actions_addfchdir_np @@ -238,9 +252,10 @@ is equal to A future update of the Standard is expected to require this behavior. .Pp The -.Fn posix_spawn_file_actions_addchdir_np +.Fn posix_spawn_file_actions_addchdir_np , +.Fn posix_spawn_file_actions_addfchdir_np , and -.Fn posix_spawn_file_actions_addfchdir_np +.Fn posix_spawn_file_actions_addclosefrom_np functions are non-standard functions implemented after the similar functionality provided by glibc. .Sh HISTORY @@ -252,9 +267,10 @@ and functions first appeared in .Fx 8.0 . The -.Fn posix_spawn_file_actions_addchdir_np +.Fn posix_spawn_file_actions_addchdir_np , +.Fn posix_spawn_file_actions_addfchdir_np , and -.Fn posix_spawn_file_actions_addfchdir_np +.Fn posix_spawn_file_actions_addclosefrom_np functions first appeared in .Fx 14.0 . .Sh AUTHORS diff --git a/lib/libc/gen/posix_spawn_file_actions_init.3 b/lib/libc/gen/posix_spawn_file_actions_init.3 index 31b62beed570..1215a04f6386 100644 --- a/lib/libc/gen/posix_spawn_file_actions_init.3 +++ b/lib/libc/gen/posix_spawn_file_actions_init.3 @@ -83,6 +83,7 @@ Insufficient memory exists to initialize the spawn file actions object. .Sh SEE ALSO .Xr posix_spawn 3 , .Xr posix_spawn_file_actions_addclose 3 , +.Xr posix_spawn_file_actions_addclosefrom_np 3 , .Xr posix_spawn_file_actions_adddup2 3 , .Xr posix_spawn_file_actions_addopen 3 , .Xr posix_spawnp 3