[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
subpipe.c simplification
From: |
Paul Eggert |
Subject: |
subpipe.c simplification |
Date: |
Fri, 11 Aug 2006 13:34:20 -0700 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
I installed this minor simplification:
2006-08-11 Paul Eggert <address@hidden>
* lib/subpipe.c (create_subpipe): Use new gnulib pipe_safer
function, since it simplifies our code a bit.
--- lib/subpipe.c 22 Jan 2006 07:38:49 -0000 1.10
+++ lib/subpipe.c 11 Aug 2006 20:30:38 -0000 1.11
@@ -113,19 +113,15 @@ create_subpipe (char const * const *argv
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 +156,7 @@ reap_subpipe (pid_t pid, char const *pro
#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;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- subpipe.c simplification,
Paul Eggert <=