[PATCH v2 4/4] posix: Add posix_spawn_file_actions_closefrom
Florian Weimer
fweimer@redhat.com
Wed Dec 23 14:27:26 GMT 2020
* Adhemerval Zanella:
> +* The posix_spawn_file_actions_closefrom_np has been added, enabling
> + posix_spawn and posix_spawnp to close all file descriptors greater than
> + a giver integer. This function is a GNU extension, although Solaris also
> + provides a similar function.
“The function posix_spawn_file_actions_closefrom_np”?
> +static void
> +do_test_closefrom (void)
> +{
> + int lowfd = xopen ("/dev/null", O_WRONLY, 0);
> + for (int i = 1; i < NFDS; i++)
> + xopen ("/dev/null", O_WRONLY, 0);
The usual observation about NFDS and fgap checking.
> + /* Create some gaps, close up to a threshold, and check result. */
> + xclose (57);
> + xclose (78);
> + xclose (81);
> + xclose (82);
> + xclose (84);
> + xclose (90);
Please add lowfd here as well.
> diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c
> index f157bfffd2..c337c7a6a1 100644
> --- a/sysdeps/unix/sysv/linux/spawni.c
> +++ b/sysdeps/unix/sysv/linux/spawni.c
> @@ -16,22 +16,17 @@
> License along with the GNU C Library; if not, see
> <https://www.gnu.org/licenses/>. */
>
> -#include <spawn.h>
> -#include <fcntl.h>
> -#include <paths.h>
> -#include <string.h>
> -#include <sys/resource.h>
> -#include <sys/wait.h>
> -#include <sys/param.h>
> -#include <sys/mman.h>
> -#include <not-cancel.h>
> +#include <arch-fd_to_filename.h>
> +#include <internal-signals.h>
> +#include <ldsodefs.h>
> #include <local-setxid.h>
> +#include <not-cancel.h>
> +#include <paths.h>
> #include <shlib-compat.h>
> -#include <nptl/pthreadP.h>
> -#include <dl-sysdep.h>
> -#include <libc-pointer-arith.h>
> -#include <ldsodefs.h>
> -#include "spawn_int.h"
> +#include <spawn.h>
> +#include <spawn_int.h>
> +#include <sysdep.h>
> +#include <sys/resource.h>
Is <arch-fd_to_filename.h> really required here?
Thanks,
Florian
--
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill
More information about the Libc-alpha
mailing list