]>
Commit | Line | Data |
---|---|---|
de56407f | 1 | /* |
2 | * $Source$ | |
3 | * $Header$ | |
4 | */ | |
5 | ||
6 | #ifndef lint | |
7 | static char *rcsid_exec_002_c = "$Header$"; | |
8 | #endif lint | |
9 | ||
10 | #include <stdio.h> | |
11 | #include <sys/wait.h> | |
6143ee87 | 12 | #include <signal.h> |
de56407f | 13 | #include "gdb.h" |
14 | #include "update.h" | |
15 | #include "sms_update_int.h" | |
16 | #include "kludge.h" | |
17 | #include "smsu_int.h" | |
18 | ||
19 | extern CONNECTION conn; | |
20 | extern int code, errno; | |
21 | ||
22 | int | |
23 | exec_002(str) | |
24 | char *str; | |
25 | { | |
26 | union wait waitb; | |
6143ee87 | 27 | int n, pid, mask; |
de56407f | 28 | |
29 | str += 8; | |
30 | while (*str == ' ') | |
31 | str++; | |
6143ee87 | 32 | mask = sigblock(sigmask(SIGCHLD)); |
de56407f | 33 | pid = fork(); |
34 | switch (pid) { | |
35 | case -1: | |
36 | n = errno; | |
6143ee87 | 37 | sigsetmask(mask); |
de56407f | 38 | log_priority = log_ERROR; |
39 | com_err(whoami, errno, ": can't fork to run install script"); | |
40 | code = send_object(conn, (char *)&n, INTEGER_T); | |
41 | if (code) | |
42 | exit(1); | |
43 | return; | |
44 | case 0: | |
45 | execlp(str, str, (char *)NULL); | |
46 | n = errno; | |
6143ee87 | 47 | sigsetmask(mask); |
de56407f | 48 | log_priority = log_ERROR; |
49 | com_err(whoami, n, ": %s", str); | |
50 | (void) send_object(conn, (char *)&n, INTEGER_T); | |
51 | exit(1); | |
52 | default: | |
53 | do { | |
54 | n = wait(&waitb); | |
55 | } while (n != -1 && n != pid); | |
6143ee87 | 56 | sigsetmask(mask); |
de56407f | 57 | if (waitb.w_status) { |
58 | log_priority = log_ERROR; | |
59 | com_err(whoami, 0, "child exited with status %d", waitb.w_status); | |
60 | code = send_object(conn, (char *)&n, INTEGER_T); | |
61 | if (code) | |
62 | exit(1); | |
63 | } | |
64 | else { | |
65 | code = send_ok(); | |
66 | if (code) | |
67 | exit(1); | |
68 | } | |
69 | } | |
70 | } |