---
name: "posix_spawnattr_getexecfd_np"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/posix_spawnattr_getexecfd_np"
---

# posix\_spawnattr\_getexecfd\_np(3)

get and set the spawn-execfd attribute of a spawn attributes object

## NAME

**posix\_spawnattr\_getexecfd\_np**, **posix\_spawnattr\_setexecfd\_np** – get and set the spawn-execfd attribute of a spawn attributes object

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

**#include \<spawn.h\>**

*int*\

**posix\_spawnattr\_getexecfd\_np**(*const posix\_spawnattr\_t \*restrict attr*, *int \*restrict fdp*);

*int*\

**posix\_spawnattr\_setexecfd\_np**(*posix\_spawnattr\_t \*attr*, *int fd*);

## DESCRIPTION

The **posix\_spawnattr\_getexecfd\_np**() function obtains the value of the spawn-execfd attribute from the attributes object referenced by *attr*.

The **posix\_spawnattr\_setexecfd\_np**() function sets the spawn-execfd attribute in an initialized attributes object referenced by *attr*.

The spawn-execfd attribute provides the file descriptor that is used to execute new image in the spawned process by the [posix\_spawn(3)](/posix_spawn/3.md) family of functions. If the attribute is set to a value other then -1, it must be a valid file descriptor which does not have the *O\_CLOFORK* flag set. Then, **posix\_spawn**() executes the executable image referenced by the file descriptor in the newly created process, using the [fexecve(2)](/fexecve/2.md) system call. In this case, the *path* argument to **posix\_spawn**() is ignored.

The default value for the spawn-execfd attribute is -1, which means that the executed image is specified by the *path* argument to **posix\_spawn**().

## RETURN VALUES

The **posix\_spawnattr\_getexecfd\_np**() and **posix\_spawnattr\_setexecfd\_np**() functions return zero.

## SEE ALSO

[posix\_spawn(3)](/posix_spawn/3.md), [posix\_spawnattr\_destroy(3)](/posix_spawnattr_destroy/3.md), [posix\_spawnattr\_init(3)](/posix_spawnattr_init/3.md), [posix\_spawnp(3)](/posix_spawnp/3.md)

## STANDARDS

The **posix\_spawnattr\_getexecfd\_np**() and **posix\_spawnattr\_setexecfd\_np**() are FreeBSD extensions that first appeared in FreeBSD 16.0.
