Commit | Line | Data |
---|---|---|
2dd7d7a6 | 1 | #ifndef lint |
eec72f58 | 2 | static char *sccsid = "@(#)wwspawn.c 3.6 83/12/01"; |
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*/ |
13 | wwspawn(wp, file, argv0) | |
2dd7d7a6 | 14 | register struct ww *wp; |
ac62cc78 | 15 | char *file, *argv0; |
2dd7d7a6 | 16 | { |
eec72f58 EW |
17 | extern int errno; |
18 | extern char *sys_errlist[]; | |
ac62cc78 EW |
19 | int pid; |
20 | ||
eec72f58 | 21 | sighold(SIGCHLD); |
ac62cc78 | 22 | switch (pid = vfork()) { |
2dd7d7a6 | 23 | case -1: |
03e75950 | 24 | wwerrno = WWE_SYS; |
eec72f58 | 25 | 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; | |
35 | sigrelse(SIGCHLD); | |
36 | return -1; | |
37 | } else { | |
38 | wp->ww_pid = pid; | |
39 | wp->ww_state = WWS_HASPROC; | |
40 | sigrelse(SIGCHLD); | |
41 | return pid; | |
42 | } | |
2dd7d7a6 EW |
43 | } |
44 | } |