diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index 47724bc347c..c1925482d8c 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -461,6 +461,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 848733a41a7..f7d54903dcb 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 b364e92c18f..0782e15b312 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 31b62beed57..1215a04f638 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