Mercurial > hg > toybox
changeset 1473:bff076394df5 draft
Second attempt at one way xpopen().
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 14 Sep 2014 19:54:19 -0500 |
parents | 2f9bc9495144 |
children | 715c765cec61 |
files | lib/xwrap.c |
diffstat | 1 files changed, 6 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/xwrap.c Sun Sep 14 12:29:44 2014 -0500 +++ b/lib/xwrap.c Sun Sep 14 19:54:19 2014 -0500 @@ -215,12 +215,14 @@ // 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)