diff options
Diffstat (limited to 'src/exec.c')
-rw-r--r-- | src/exec.c | 23 |
1 files changed, 18 insertions, 5 deletions
@@ -30,16 +30,29 @@ start_prog (int argc, const char **argv, pid_t *ppid) | |||
30 | pid_t pid; | 30 | pid_t pid; |
31 | int i; | 31 | int i; |
32 | 32 | ||
33 | pipe (p); | 33 | if (pipe (p)) |
34 | { | ||
35 | logmsg (LOG_CRIT, "pipe: %s", strerror (errno)); | ||
36 | return NULL; | ||
37 | } | ||
38 | |||
34 | switch (pid = fork ()) | 39 | switch (pid = fork ()) |
35 | { | 40 | { |
36 | case 0: | 41 | case 0: |
37 | /* Child process */ | 42 | /* Child process */ |
38 | 43 | ||
39 | if (p[1] != 1) | 44 | if (p[1] != 1 && dup2 (p[1], 1) == -1) |
40 | dup2 (p[1], 1); | 45 | { |
41 | if (p[1] != 1) | 46 | logmsg (LOG_CRIT, "dup2: %s", strerror (errno)); |
42 | dup2 (p[1], 2); | 47 | _exit (EX_UNAVAILABLE); |
48 | } | ||
49 | |||
50 | if (p[1] != 1 && dup2 (p[1], 2) == -1) | ||
51 | { | ||
52 | logmsg (LOG_CRIT, "dup2: %s", strerror (errno)); | ||
53 | _exit (EX_UNAVAILABLE); | ||
54 | } | ||
55 | |||
43 | close (p[0]); | 56 | close (p[0]); |
44 | 57 | ||
45 | /* Close unneded descripitors */ | 58 | /* Close unneded descripitors */ |