---
name: "posix_spawnattr_destroy"
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_destroy"
---

# posix\_spawnattr\_destroy(3)

initialize and destroy spawn attributes object

## NAME

**posix\_spawnattr\_init**, **posix\_spawnattr\_destroy** – initialize and destroy spawn attributes object

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

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

*int*\

**posix\_spawnattr\_init**(*posix\_spawnattr\_t \* attr*);

*int*\

**posix\_spawnattr\_destroy**(*posix\_spawnattr\_t \* attr*);

## DESCRIPTION

The **posix\_spawnattr\_init**() function initializes a spawn attributes object *attr* with the default value for all of the individual attributes used by the implementation. Initializing an already initialized spawn attributes object may cause memory to be leaked.

The **posix\_spawnattr\_destroy**() function destroys a spawn attributes object. A destroyed *attr* attributes object can be reinitialized using **posix\_spawnattr\_init**(). The object should not be used after it has been destroyed.

A spawn attributes object is of type *posix\_spawnattr\_t* (defined in ⟨spawn.h⟩) and is used to specify the inheritance of process attributes across a spawn operation.

The resulting spawn attributes object (possibly modified by setting individual attribute values), is used to modify the behavior of **posix\_spawn**() or **posix\_spawnp**(). After a spawn attributes object has been used to spawn a process by a call to a **posix\_spawn**() or **posix\_spawnp**(), any function affecting the attributes object (including destruction) will not affect any process that has been spawned in this way.

## RETURN VALUES

Upon successful completion, **posix\_spawnattr\_init**() and **posix\_spawnattr\_destroy**() return zero; otherwise, an error number is returned to indicate the error.

## ERRORS

The **posix\_spawnattr\_init**() function will fail if:

- \[ENOMEM\]

  Insufficient memory exists to initialize the spawn attributes object.

## SEE ALSO

[posix\_spawn(3)](/posix_spawn/3.md), [posix\_spawnp(3)](/posix_spawnp/3.md)

## STANDARDS

The **posix\_spawnattr\_init**() and **posix\_spawnattr\_destroy**() functions conform to IEEE Std 1003.1-2001 (“POSIX.1”).

## HISTORY

The **posix\_spawnattr\_init**() and **posix\_spawnattr\_destroy**() functions first appeared in FreeBSD 8.0.

## AUTHORS

Ed Schouten ⟨*ed@FreeBSD.org*⟩
