]>
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> | |
12 | #include "gdb.h" | |
13 | #include "update.h" | |
14 | #include "sms_update_int.h" | |
15 | #include "kludge.h" | |
16 | #include "smsu_int.h" | |
17 | ||
18 | extern CONNECTION conn; | |
19 | extern int code, errno; | |
20 | ||
21 | int | |
22 | exec_002(str) | |
23 | char *str; | |
24 | { | |
25 | union wait waitb; | |
26 | int n, pid; | |
27 | ||
28 | str += 8; | |
29 | while (*str == ' ') | |
30 | str++; | |
31 | pid = fork(); | |
32 | switch (pid) { | |
33 | case -1: | |
34 | n = errno; | |
35 | log_priority = log_ERROR; | |
36 | com_err(whoami, errno, ": can't fork to run install script"); | |
37 | code = send_object(conn, (char *)&n, INTEGER_T); | |
38 | if (code) | |
39 | exit(1); | |
40 | return; | |
41 | case 0: | |
42 | execlp(str, str, (char *)NULL); | |
43 | n = errno; | |
44 | log_priority = log_ERROR; | |
45 | com_err(whoami, n, ": %s", str); | |
46 | (void) send_object(conn, (char *)&n, INTEGER_T); | |
47 | exit(1); | |
48 | default: | |
49 | do { | |
50 | n = wait(&waitb); | |
51 | } while (n != -1 && n != pid); | |
52 | if (waitb.w_status) { | |
53 | log_priority = log_ERROR; | |
54 | com_err(whoami, 0, "child exited with status %d", waitb.w_status); | |
55 | code = send_object(conn, (char *)&n, INTEGER_T); | |
56 | if (code) | |
57 | exit(1); | |
58 | } | |
59 | else { | |
60 | code = send_ok(); | |
61 | if (code) | |
62 | exit(1); | |
63 | } | |
64 | } | |
65 | } |