aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-09-14 19:54:19 -0500
committerRob Landley <rob@landley.net>2014-09-14 19:54:19 -0500
commit8a9907119bf22f2279470be40cf40027dc37018c (patch)
tree183bbddc0a27bc71fff5d69f01e4869672ad79f7 /lib
parent360d57f843f5435a75270e54583430dcb8f62546 (diff)
downloadtoybox-8a9907119bf22f2279470be40cf40027dc37018c.tar.gz
Second attempt at one way xpopen().
Diffstat (limited to 'lib')
-rw-r--r--lib/xwrap.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/xwrap.c b/lib/xwrap.c
index 64b183ff..341aac35 100644
--- a/lib/xwrap.c
+++ b/lib/xwrap.c
@@ -215,12 +215,14 @@ int xpclose_both(pid_t pid, int *pipes)
// Wrapper to xpopen with a pipe for just one of stdin/stdout
pid_t xpopen(char **argv, int *pipe, int stdout)
{
- int pipes[2];
+ int pipes[2], pid;
- pipe[!stdout] = -1;
- pipe[!!stdout] = 0;
+ pipes[!stdout] = -1;
+ pipes[!!stdout] = 0;
+ pid = xpopen_both(argv, pipes);
+ *pipe = pid ? pipes[!!stdout] : -1;
- return xpopen_both(argv, pipes);
+ return pid;
}
int xpclose(pid_t pid, int pipe)