mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
* lib/subpipe.c (create_subpipe): Use new gnulib pipe_safer
function, since it simplifies our code a bit.
This commit is contained in:
@@ -113,19 +113,15 @@ create_subpipe (char const * const *argv, int fd[2])
|
|||||||
int child_fd[2];
|
int child_fd[2];
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
if (pipe (child_fd) != 0
|
if (pipe_safer (child_fd) != 0 || pipe_safer (pipe_fd) != 0)
|
||||||
|| (child_fd[0] = fd_safer (child_fd[0])) < 0
|
error (EXIT_FAILURE, errno, "pipe");
|
||||||
|| (fd[0] = fd_safer (child_fd[1])) < 0
|
fd[0] = child_fd[1];
|
||||||
|| pipe (pipe_fd) != 0
|
fd[1] = pipe_fd[0];
|
||||||
|| (fd[1] = fd_safer (pipe_fd[0])) < 0
|
child_fd[1] = pipe_fd[1];
|
||||||
|| (child_fd[1] = fd_safer (pipe_fd[1])) < 0)
|
|
||||||
error (EXIT_FAILURE, errno,
|
|
||||||
"pipe");
|
|
||||||
|
|
||||||
pid = vfork ();
|
pid = vfork ();
|
||||||
if (pid < 0)
|
if (pid < 0)
|
||||||
error (EXIT_FAILURE, errno,
|
error (EXIT_FAILURE, errno, "fork");
|
||||||
"fork");
|
|
||||||
|
|
||||||
if (! pid)
|
if (! pid)
|
||||||
{
|
{
|
||||||
@@ -160,8 +156,7 @@ reap_subpipe (pid_t pid, char const *program)
|
|||||||
#if HAVE_WAITPID || defined waitpid
|
#if HAVE_WAITPID || defined waitpid
|
||||||
int wstatus;
|
int wstatus;
|
||||||
if (waitpid (pid, &wstatus, 0) < 0)
|
if (waitpid (pid, &wstatus, 0) < 0)
|
||||||
error (EXIT_FAILURE, errno,
|
error (EXIT_FAILURE, errno, "waitpid");
|
||||||
"waitpid");
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int status = WIFEXITED (wstatus) ? WEXITSTATUS (wstatus) : -1;
|
int status = WIFEXITED (wstatus) ? WEXITSTATUS (wstatus) : -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user