author | Olivier Brunel
<jjk@jjacky.com> 2016-01-03 20:45:18 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2016-01-09 12:30:52 UTC |
parent | 613dc22100dcaec4497bc5a92b3e99ae3a708ec5 |
src/libanopa/exec_oneshot.c | +41 | -15 |
diff --git a/src/libanopa/exec_oneshot.c b/src/libanopa/exec_oneshot.c index a3ba683..71efb32 100644 --- a/src/libanopa/exec_oneshot.c +++ b/src/libanopa/exec_oneshot.c @@ -105,7 +105,7 @@ _exec_oneshot (int si, aa_mode mode) _err = "set up pipes"; goto err; } - if (pipenb (p_in) < 0) + if (pipe (p_in) < 0) { _errno = errno; _err = "set up pipes"; @@ -115,23 +115,19 @@ _exec_oneshot (int si, aa_mode mode) goto err; } - else + else if (ndelay_on (p_in[1]) < 0 || coe (p_in[1]) < 0) { - int flags = fcntl (p_in[0], F_GETFL, 0); - if (flags < 0 || fcntl (p_in[0], F_SETFL, flags & ~O_NONBLOCK) < 0) - { - _errno = errno; - _err = "set up pipes"; + _errno = errno; + _err = "set up pipes"; - fd_close (p_int[0]); - fd_close (p_int[1]); - fd_close (p_in[0]); - fd_close (p_in[1]); + fd_close (p_int[0]); + fd_close (p_int[1]); + fd_close (p_in[0]); + fd_close (p_in[1]); - goto err; - } + goto err; } - if (pipenb (p_out) < 0) + if (pipe (p_out) < 0) { _errno = errno; _err = "set up pipes"; @@ -143,7 +139,7 @@ _exec_oneshot (int si, aa_mode mode) goto err; } - if (pipenb (p_prg) < 0) + else if (ndelay_on (p_out[0]) < 0 || coe (p_out[0]) < 0) { _errno = errno; _err = "set up pipes"; @@ -157,6 +153,36 @@ _exec_oneshot (int si, aa_mode mode) goto err; } + if (pipe (p_prg) < 0) + { + _errno = errno; + _err = "set up pipes"; + + fd_close (p_int[0]); + fd_close (p_int[1]); + fd_close (p_in[0]); + fd_close (p_in[1]); + fd_close (p_out[0]); + fd_close (p_out[1]); + + goto err; + } + else if (ndelay_on (p_prg[0]) < 0 || coe (p_prg[0]) < 0) + { + _errno = errno; + _err = "set up pipes"; + + fd_close (p_int[0]); + fd_close (p_int[1]); + fd_close (p_in[0]); + fd_close (p_in[1]); + fd_close (p_out[0]); + fd_close (p_out[1]); + fd_close (p_prg[0]); + fd_close (p_prg[1]); + + goto err; + } pid = fork (); if (pid < 0)