spawnveg - process spawn with process group and session control
#include <ast.h>
int spawnveg(const char* command, char** argv, char** envv, pid_t pgid);
spwanveg
combines
fork(2),
exec(2),
setpgid(2)
and
setsid(2)
into a single call.
command,
argv
and
envv
are as in
execve(2).
pgid
controls the new process group and session:
- <0
-
The new process becomes a session leader.
is called in the child context.
- 0
-
The new process is in the callers process group.
- 1
-
The new process becomes a process group leader.
- >1
-
The new process joins the process group
pgid.
It is possible to code all process creation (except for
vfork(2)
hack like in
csh(1))
using
spawnveg.
The
proc(3)
routines and
ksh(1)
do this on systems that don't support
fork(2).
This makes porting to NT and Windows a snap: a simple
iffe(1)
probe provides a
spawnveg
implementation using the NT or Windows process primitives.
fork(2), exec(2), setpgid(2), setsid(2), spawnve(2)