put in | for vertical lines, - for horizontal lines.
[unix-history] / usr / src / usr.bin / window / wwspawn.c
CommitLineData
2dd7d7a6 1#ifndef lint
57c34fd1 2static char *sccsid = "@(#)wwspawn.c 3.7 84/01/13";
2dd7d7a6
EW
3#endif
4
5#include "ww.h"
eec72f58 6#include <signal.h>
2dd7d7a6 7
eec72f58
EW
8/*
9 * There is a dead lock with vfork and closing of pseudo-ports.
10 * So we have to be sneaky.
11 */
ac62cc78
EW
12/*VARARGS3*/
13wwspawn(wp, file, argv0)
2dd7d7a6 14register struct ww *wp;
ac62cc78 15char *file, *argv0;
2dd7d7a6 16{
eec72f58
EW
17 extern int errno;
18 extern char *sys_errlist[];
ac62cc78
EW
19 int pid;
20
57c34fd1 21 (void) sighold(SIGCHLD);
ac62cc78 22 switch (pid = vfork()) {
2dd7d7a6 23 case -1:
03e75950 24 wwerrno = WWE_SYS;
57c34fd1 25 (void) sigrelse(SIGCHLD);
2dd7d7a6
EW
26 return -1;
27 case 0:
4711df8b 28 wwenviron(wp);
eec72f58 29 errno = 0;
ac62cc78 30 execv(file, &argv0);
eec72f58 31 _exit(1);
2dd7d7a6 32 default:
eec72f58
EW
33 if (errno != 0) {
34 wwerrno = WWE_SYS;
57c34fd1 35 (void) sigrelse(SIGCHLD);
eec72f58
EW
36 return -1;
37 } else {
38 wp->ww_pid = pid;
39 wp->ww_state = WWS_HASPROC;
57c34fd1 40 (void) sigrelse(SIGCHLD);
eec72f58
EW
41 return pid;
42 }
2dd7d7a6
EW
43 }
44}