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

# posix\_spawnattr\_setpgroup(3)

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

Part of [posix\_spawnattr\_getpgroup(3)](/posix_spawnattr_getpgroup/3.md).

## NAME

**posix\_spawnattr\_getpgroup**, **posix\_spawnattr\_setpgroup** – get and set the spawn-pgroup attribute of a spawn attributes object

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

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

*int*\

**posix\_spawnattr\_getpgroup**(*const posix\_spawnattr\_t \*restrict attr*, *pid\_t \*restrict pgroup*);

*int*\

**posix\_spawnattr\_setpgroup**(*posix\_spawnattr\_t \*attr*, *pid\_t pgroup*);

## DESCRIPTION

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

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

The spawn-pgroup attribute represents the process group to be joined by the new process image in a spawn operation (if POSIX\_SPAWN\_SETPGROUP is set in the spawn-flags attribute). The default value of this attribute is zero.

## RETURN VALUES

The **posix\_spawnattr\_getpgroup**() and **posix\_spawnattr\_setpgroup**() 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\_getpgroup**() and **posix\_spawnattr\_setpgroup**() functions conform to IEEE Std 1003.1-2001 (“POSIX.1”).

## HISTORY

The **posix\_spawnattr\_getpgroup**() and **posix\_spawnattr\_setpgroup**() functions first appeared in FreeBSD 8.0.

## AUTHORS

Ed Schouten ⟨*ed@FreeBSD.org*⟩
