aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2018-06-19 13:59:16 -0500
committerWilliam Hubbs <w.d.hubbs@gmail.com>2018-06-19 13:59:16 -0500
commit47e4bfae57402eedd017d6098b432c2c411cd374 (patch)
tree5c80bf675a33eaa18c5af54bd25088fbbdc84759 /src
parent8a945194afb106428bc700e751078ef9944ee617 (diff)
fix gcc 7 warnings in pipe routines
Diffstat (limited to 'src')
-rw-r--r--src/rc/rc-pipes.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/rc/rc-pipes.c b/src/rc/rc-pipes.c
index 2d7b623e..70fefa80 100644
--- a/src/rc/rc-pipes.c
+++ b/src/rc/rc-pipes.c
@@ -37,21 +37,20 @@ int rc_pipe_command(char *cmd)
return -1;
pid = fork();
- if (pid < 0)
- return -1;
- else if (pid > 0) {
+ if (pid > 0) {
/* parent */
- close(pfd[0]);
+ close(pfd[pipe_read_end]);
return pfd[pipe_write_end];
} else if (pid == 0) {
/* child */
close(pfd[pipe_write_end]);
- if (pfd[0] != STDIN_FILENO) {
- if (dup2(pfd[0], STDIN_FILENO) < 0)
+ if (pfd[pipe_read_end] != STDIN_FILENO) {
+ if (dup2(pfd[pipe_read_end], STDIN_FILENO) < 0)
exit(1);
- close(pfd[0]);
+ close(pfd[pipe_read_end]);
}
execl("/bin/sh", "sh", "-c", cmd, NULL);
exit(1);
}
+ return -1;
}