Skip to content
BSD syscall#82

svc · unix #82

setpgid

Joins or creates a process group for the specified process.

Prototype

int setpgid(int pid, int pgid);

Returns: int

Arguments

NameTypeDirDescription
pidint-
pgidint-

Version history

XNU tagmacOS#
xnu-1456.1.26macOS 10.6 Snow Leopard82
xnu-1699.24.8macOS 10.7 Lion82
xnu-2050.18.24macOS 10.8 Mountain Lion82
xnu-2422.115.4macOS 10.9 Mavericks82
xnu-2782.40.9macOS 10.10 Yosemite82
xnu-3247.1.106macOS 10.11 El Capitan82
xnu-3789.1.32macOS 10.12 Sierra82
xnu-4570.1.46macOS 10.13 High Sierra82
xnu-4903.221.2macOS 10.14 Mojave82
xnu-6153.11.26macOS 10.15 Catalina82
xnu-7195.50.7.100.1macOS 11.0 Big Sur82
xnu-8019.41.5macOS 12.0 Monterey82
xnu-8792.41.9macOS 13.0 Ventura82
xnu-10002.1.13macOS 14.0 Sonoma82
xnu-11215.1.10macOS 15.0 Sequoia82
xnu-11417.101.15macOS 15.4 Sequoia82
xnu-12377.1.9macOS 26.0 Tahoe82
xnu-10002.41.982
xnu-10002.61.382
xnu-10002.81.582
xnu-10063.101.1582
xnu-10063.121.382
xnu-10063.141.182
xnu-11215.41.382
xnu-11215.61.582
xnu-11215.81.482
xnu-11417.121.682
xnu-11417.140.6982
xnu-12377.101.1582
xnu-12377.41.682
xnu-12377.61.1282
xnu-12377.81.482
xnu-1486.2.1182
xnu-1504.15.382
xnu-1504.3.1282
xnu-1504.7.482
xnu-1504.9.1782
xnu-1504.9.2682
xnu-1504.9.3782
xnu-1699.22.7382
xnu-1699.22.8182
xnu-1699.24.2382
xnu-1699.26.882
xnu-1699.32.782
xnu-2050.22.1382
xnu-2050.24.1582
xnu-2050.48.1182
xnu-2050.7.982
xnu-2050.9.282
xnu-2422.1.7282
xnu-2422.100.1382
xnu-2422.110.1782
xnu-2422.90.2082
xnu-2782.1.9782
xnu-2782.10.7282
xnu-2782.20.4882
xnu-2782.30.582
xnu-3247.10.1182
xnu-3248.20.5582
xnu-3248.30.482
xnu-3248.40.18482
xnu-3248.50.2182
xnu-3248.60.1082
xnu-3789.21.482
xnu-3789.31.282
xnu-3789.41.382
xnu-3789.51.282
xnu-3789.60.2482
xnu-3789.70.1682
xnu-4570.20.6282
xnu-4570.31.382
xnu-4570.41.282
xnu-4570.51.182
xnu-4570.61.182
xnu-4570.71.282
xnu-4903.231.482
xnu-4903.241.182
xnu-4903.270.4782
xnu-6153.101.682
xnu-6153.121.182
xnu-6153.141.182
xnu-6153.41.382
xnu-6153.61.182
xnu-6153.81.582
xnu-7195.101.182
xnu-7195.121.382
xnu-7195.141.282
xnu-7195.60.7582
xnu-7195.81.382
xnu-8019.61.582
xnu-8019.80.2482
xnu-8020.101.482
xnu-8020.121.382
xnu-8020.140.4182
xnu-8792.61.282
xnu-8792.81.282
xnu-8796.101.582
xnu-8796.121.282
xnu-8796.141.382

Notes

Both arguments may be 0 to operate on the caller and create a new group with PID equal to the caller's PID. Used by shells immediately after fork() so the child is placed in its own pgid before exec, enabling clean job control. The target must be in the same session as the caller and must not have called execve() yet (EACCES).

Related APIs

getpgidgetpgrpsetsidgetsidfork