1.\" Copyright 2026 The FreeBSD Foundation 2.\" 3.\" SPDX-License-Identifier: BSD-2-Clause 4.\" 5.\" This documentation was written by 6.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship 7.\" from the FreeBSD Foundation. 8.\" 9.Dd January 25, 2026 10.Dt POSIX_SPAWNATTR_GETEXECFD_NP 3 11.Os 12.Sh NAME 13.Nm posix_spawnattr_getexecfd_np , 14.Nm posix_spawnattr_setexecfd_np 15.Nd "get and set the spawn-execfd attribute of a spawn attributes object" 16.Sh LIBRARY 17.Lb libc 18.Sh SYNOPSIS 19.In spawn.h 20.Ft int 21.Fo posix_spawnattr_getexecfd_np 22.Fa "const posix_spawnattr_t *restrict attr" 23.Fa "int *restrict fdp" 24.Fc 25.Ft int 26.Fo posix_spawnattr_setexecfd_np 27.Fa "posix_spawnattr_t *attr" 28.Fa "int fd" 29.Fc 30.Sh DESCRIPTION 31The 32.Fn posix_spawnattr_getexecfd_np 33function obtains the value of the spawn-execfd attribute from the 34attributes object referenced by 35.Fa attr . 36.Pp 37The 38.Fn posix_spawnattr_setexecfd_np 39function sets the spawn-execfd attribute in an initialized attributes 40object referenced by 41.Fa attr . 42.Pp 43The spawn-execfd attribute provides the file descriptor that is used 44to execute new image in the spawned process by the 45.Xr posix_spawn 3 46family of functions. 47If the attribute is set to a value other then \-1, it must be a valid 48file descriptor which does not have the 49.Va O_CLOFORK 50flag set. 51Then, 52.Fn posix_spawn 53executes the executable image referenced by the file descriptor in the 54newly created process, using the 55.Xr fexecve 2 56system call. 57In this case, the 58.Fa path 59argument to 60.Fn posix_spawn 61is ignored. 62.Pp 63The default value for the spawn-execfd attribute is \-1, which 64means that the executed image is specified by the 65.Fa path 66argument to 67.Fn posix_spawn . 68.Sh RETURN VALUES 69The 70.Fn posix_spawnattr_getexecfd_np 71and 72.Fn posix_spawnattr_setexecfd_np 73functions return zero. 74.Sh SEE ALSO 75.Xr posix_spawn 3 , 76.Xr posix_spawnattr_destroy 3 , 77.Xr posix_spawnattr_init 3 , 78.Xr posix_spawnp 3 79.Sh STANDARDS 80The 81.Fn posix_spawnattr_getexecfd_np 82and 83.Fn posix_spawnattr_setexecfd_np 84are 85.Fx 86extensions that first appeared in 87.Fx 16.0 . 88