X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/02650b7f0e3ef470a949768bdb907183da4b3beb..e32050b0c73c9ea7be5aee0de5a0e7f15ec3538f:/lib/subpipe.c
diff --git a/lib/subpipe.c b/lib/subpipe.c
index 646aa8ec..1b7c36d8 100644
--- a/lib/subpipe.c
+++ b/lib/subpipe.c
@@ -1,11 +1,12 @@
/* Subprocesses with pipes.
- Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004-2006, 2009-2010 Free Software Foundation,
+ Inc.
- This program is free software; you can redistribute it and/or modify
+ This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -13,15 +14,12 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+ along with this program. If not, see . */
/* Written by Paul Eggert
and Florian Krohm . */
-#ifdef HAVE_CONFIG_H
-# include
-#endif
+#include
#include "subpipe.h"
@@ -34,9 +32,7 @@
#include
-#if HAVE_UNISTD_H
-# include
-#endif
+#include
#ifndef STDIN_FILENO
# define STDIN_FILENO 0
#endif
@@ -113,19 +109,15 @@ create_subpipe (char const * const *argv, int fd[2])
int child_fd[2];
pid_t pid;
- if (pipe (child_fd) != 0
- || (child_fd[0] = fd_safer (child_fd[0])) < 0
- || (fd[0] = fd_safer (child_fd[1])) < 0
- || pipe (pipe_fd) != 0
- || (fd[1] = fd_safer (pipe_fd[0])) < 0
- || (child_fd[1] = fd_safer (pipe_fd[1])) < 0)
- error (EXIT_FAILURE, errno,
- "pipe");
+ if (pipe_safer (child_fd) != 0 || pipe_safer (pipe_fd) != 0)
+ error (EXIT_FAILURE, errno, "pipe");
+ fd[0] = child_fd[1];
+ fd[1] = pipe_fd[0];
+ child_fd[1] = pipe_fd[1];
pid = vfork ();
if (pid < 0)
- error (EXIT_FAILURE, errno,
- "fork");
+ error (EXIT_FAILURE, errno, "fork");
if (! pid)
{
@@ -160,8 +152,7 @@ reap_subpipe (pid_t pid, char const *program)
#if HAVE_WAITPID || defined waitpid
int wstatus;
if (waitpid (pid, &wstatus, 0) < 0)
- error (EXIT_FAILURE, errno,
- "waitpid");
+ error (EXIT_FAILURE, errno, "waitpid");
else
{
int status = WIFEXITED (wstatus) ? WEXITSTATUS (wstatus) : -1;