summaryrefslogtreecommitdiffabout
path: root/src/exec.c
Side-by-side diff
Diffstat (limited to 'src/exec.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/exec.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/exec.c b/src/exec.c
index e92fe17..9af6de2 100644
--- a/src/exec.c
+++ b/src/exec.c
@@ -30,16 +30,29 @@ start_prog (int argc, const char **argv, pid_t *ppid)
pid_t pid;
int i;
- pipe (p);
+ if (pipe (p))
+ {
+ logmsg (LOG_CRIT, "pipe: %s", strerror (errno));
+ return NULL;
+ }
+
switch (pid = fork ())
{
case 0:
/* Child process */
- if (p[1] != 1)
- dup2 (p[1], 1);
- if (p[1] != 1)
- dup2 (p[1], 2);
+ if (p[1] != 1 && dup2 (p[1], 1) == -1)
+ {
+ logmsg (LOG_CRIT, "dup2: %s", strerror (errno));
+ _exit (EX_UNAVAILABLE);
+ }
+
+ if (p[1] != 1 && dup2 (p[1], 2) == -1)
+ {
+ logmsg (LOG_CRIT, "dup2: %s", strerror (errno));
+ _exit (EX_UNAVAILABLE);
+ }
+
close (p[0]);
/* Close unneded descripitors */

Return to:

Send suggestions and report system problems to the System administrator.