1.fp 5 CW 2.de Af 3.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2 4.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9" 5.. 6.de aF 7.ie \\$3 .ft \\$1 8.el \{\ 9.ds ;G \& 10.nr ;G \\n(.f 11.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9" 12\\*(;G 13.ft \\n(;G \} 14.. 15.de L 16.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" 17.. 18.de LR 19.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" 20.. 21.de RL 22.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" 23.. 24.de EX \" start example 25.ta 1i 2i 3i 4i 5i 6i 26.PP 27.RS 28.PD 0 29.ft 5 30.nf 31.. 32.de EE \" end example 33.fi 34.ft 35.PD 36.RE 37.PP 38.. 39.TH SPAWNVEG 3 40.SH NAME 41spawnveg \- process spawn with process group and session control 42.SH SYNOPSIS 43.L "#include <ast.h>" 44.sp 45.L "int spawnveg(const char* command, char** argv, char** envv, pid_t pgid);" 46.SH DESCRIPTION 47.L spwanveg 48combines 49.IR fork (2), 50.IR exec (2), 51.IR setpgid (2) 52and 53.IR setsid (2) 54into a single call. 55.PP 56.LR command , 57.L argv 58and 59.L envv 60are as in 61.IR execve (2). 62.L pgid 63controls the new process group and session: 64.TP 65.L <0 66The new process becomes a session leader. 67is called in the child context. 68.TP 69.L 0 70The new process is in the callers process group. 71.TP 72.L 1 73The new process becomes a process group leader. 74.TP 75.L >1 76The new process joins the process group 77.IR pgid . 78.SH COMMENTS 79It is possible to code all process creation (except for 80.IR vfork (2) 81hack like in 82.IR csh (1)) 83using 84.LR spawnveg . 85The 86.IR proc (3) 87routines and 88.IR ksh (1) 89do this on systems that don't support 90.IR fork (2). 91This makes porting to NT and Windows a snap: a simple 92.IR iffe (1) 93probe provides a 94.L spawnveg 95implementation using the NT or Windows process primitives. 96.SH "SEE ALSO" 97fork(2), exec(2), setpgid(2), setsid(2), spawnve(2) 98