---
name: "posix_spawnattr_setpgroup"
section: "3"
platform: "macos"
package: "xnu"
version: "12377.121.6"
release: "macOS 26.5"
platforms: ["freebsd", "macos"]
url: "https://new.carta.tech/posix_spawnattr_setpgroup"
---

# posix\_spawnattr\_setpgroup(3)

set or get the spawn-pgroup attribute on a posix\_spawnattr\_t

## NAME

**posix\_spawnattr\_setpgroup** **posix\_spawnattr\_getpgroup** – set or get the *spawn-pgroup* attribute on a *posix\_spawnattr\_t*

## SYNOPSIS

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

*int*\

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

*int*\

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

## DESCRIPTION

The **posix\_spawnattr\_setpgroup**() function sets the *pgroup* on the attributes object referenced by *attr*.

The **posix\_spawnattr\_getpgroup**() function retrieves the *pgroup* on the attributes object referenced by *attr*.

The argument *pgroup* is the process group to be joined or created when the new process is created if the *POSIX\_SPAWN\_SETPGROUP* flag is set in the *posix\_spawnattr\_t* via a call to [posix\_spawnattr\_setflags(3)](/posix_spawnattr_setflags/3.md); its default value is 0, which means a new process group will be created.

## RETURN VALUES

On success, these functions return 0; on failure they return an error number from ⟨errno.h⟩. Additionally, if successful, **posix\_spawnattr\_getpgroup**() will modify the contents of the *pgroup* parameter with the current attribute value.

## ERRORS

These functions may fail if:

- \[EINVAL\]

  The value specified by *attr* is invalid.

- \[EINVAL\]

  The value of *attr* is invalid.

## SEE ALSO

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

## STANDARDS

Version 3 of the Single UNIX Specification (“SUSv3”)

## HISTORY

The **posix\_spawnattr\_setpgroup**() and **posix\_spawnattr\_getpgroup**() function calls appeared in Version 3 of the Single UNIX Specification (“SUSv3”).
