OS Manuals

spawnveg(3ast)

spawnveg - process spawn with process group and session control

SPAWNVEG(3ast) SPAWNVEG(3ast)

spawnveg - process spawn with process group and session control

#include <ast.h>

int spawnveg(const char* command, char** argv, char** envv, pid_t pgid, int tcfd);

spawnveg combines fork(2), exec(2), setpgid(2) and setsid(2) into a single call. If posix_spawn(3) is available, that function is preferred over fork.

command, argv and envv are as in execve(2). pgid controls the new process group and session:

-1
The new process becomes a session leader. setsid(2) is called in the child context.
0
The new process is in the caller's process group.
1
The new process becomes a process group leader.
>1
The new process joins the process group pgid.

The tcfd argument is currently only used if the operating system supports the posix_spawn_file_actions_addtcsetpgrp_np function. When tcfd is >=0, spawnveg will set the controlling terminal for the new process to tcfd.

If the posix_spawn_file_actions_addtcsetpgrp_np function is not available, then spawnveg cannot reliably set the terminal process group. As a result, it is incompatible with job control when used with terminals. Additionally, if the POSIX_SPAWN_SETSID attribute is not supported, then spawnveg cannot make the new process a session leader when using the posix_spawn API.

fork(2), posix_spawn(3), exec(2), setpgid(2), setsid(2), spawnve(2)

ksh 1.0.10-r36 · os · ingested 2026-09-30