POSIX_SPAWNATTR_GETEXECFD_NP(3)
π
posix_spawnattr_getexecfd_np(3) β the spawn-execfd attribute, bestie edition
okay so this one lives in the Library Functions Manual, section 3, and it's a real one β posix_spawnattr_getexecfd_np and posix_spawnattr_setexecfd_np, a little getter/setter duo for the spawn-execfd attribute on 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) β she's built in, no extra shopping required β¨
π¦ 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
okay so picture this: posix_spawnattr_getexecfd_np() reaches into the attributes object that attr points at and obtains the value of the spawn-execfd attribute. she's just reading the vibe check result, no cap π«Ά
then posix_spawnattr_setexecfd_np() does the opposite β it sets the spawn-execfd attribute on an initialized attributes object referenced by attr. main character energy, she's the one writing π
so what IS this attribute, you ask? good question bestie. the spawn-execfd attribute hands over the file descriptor that the posix_spawn(3) family of functions uses to execute the new image in the spawned process. iconic behavior β¨
here's the important part, don't skip it π β if the attribute is set to a value other than -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) system call. and in that case? the path argument to posix_spawn() is ignored. literally thrown away, not even a look ππ
the default value for the spawn-execfd attribute is -1, which means the executed image is specified by the path argument to posix_spawn(). so that's the "business as usual" setting π
β real talk: non--1means the fd has to be legit and must not carryO_CLOFORK. don't play with that one π
π RETURN VALUES
posix_spawnattr_getexecfd_np() and posix_spawnattr_setexecfd_np() both return zero. that's it. zero. slay, no drama, no mysterious negative numbers to debug at 3am π
π SEE ALSO
the whole friend group, go say hi π¦
π STANDARDS
posix_spawnattr_getexecfd_np() and posix_spawnattr_setexecfd_np() are FreeBSD extensions that first appeared in FreeBSD 16.0. so she's not POSIX, she's not portable, she's FreeBSD's girlie πΈ
and that's the page, bestie! π«Ά this one came from Debian, dated January 25, 2026, and the footer signs off as POSIX_SPAWNATTR_GETEXECFD_NP(3) β mwah, go read the source next, iykyk πβ¨
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π the page's license: BSD-2-Clause
- Copyright 2026 The FreeBSD Foundation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms