projects
/
bison.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
df9a1ba
)
(create_subpipe): Rewrite slightly to avoid warnings from GCC 4.
author
Paul Eggert
<eggert@cs.ucla.edu>
Wed, 20 Jul 2005 21:12:54 +0000
(21:12 +0000)
committer
Paul Eggert
<eggert@cs.ucla.edu>
Wed, 20 Jul 2005 21:12:54 +0000
(21:12 +0000)
lib/subpipe.c
patch
|
blob
|
blame
|
history
diff --git
a/lib/subpipe.c
b/lib/subpipe.c
index cfc94262c9b1b0672a9e622d92793822c45ffb66..10b62f2c30b9d7135233356b287fe031b0f68ed3 100644
(file)
--- a/
lib/subpipe.c
+++ b/
lib/subpipe.c
@@
-100,27
+100,17
@@
pid_t
create_subpipe (char const * const *argv, int fd[2])
{
int pipe_fd[2];
create_subpipe (char const * const *argv, int fd[2])
{
int pipe_fd[2];
- int from_in_fd;
- int from_out_fd;
- int to_in_fd;
- int to_out_fd;
+ int child_fd[2];
pid_t pid;
pid_t pid;
- if (pipe (
pipe
_fd) != 0
- || (
to_in_fd = fd_safer (pipe
_fd[0])) < 0
- || (
to_out_fd = fd_safer (pipe
_fd[1])) < 0
+ 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
|| pipe (pipe_fd) != 0
- || (f
rom_in_fd
= fd_safer (pipe_fd[0])) < 0
- || (
from_out_fd
= fd_safer (pipe_fd[1])) < 0)
+ || (f
d[1]
= fd_safer (pipe_fd[0])) < 0
+ || (
child_fd[1]
= fd_safer (pipe_fd[1])) < 0)
error (EXIT_FAILURE, errno, "pipe");
error (EXIT_FAILURE, errno, "pipe");
- /* Save the local variables in the parent now, in case vfork
- clobbers them. */
- fd[0] = to_out_fd;
- fd[1] = from_in_fd;
- pipe_fd[0] = to_in_fd;
- pipe_fd[1] = from_out_fd;
-
pid = vfork ();
if (pid < 0)
error (EXIT_FAILURE, errno, "fork");
pid = vfork ();
if (pid < 0)
error (EXIT_FAILURE, errno, "fork");
@@
-128,12
+118,12
@@
create_subpipe (char const * const *argv, int fd[2])
if (! pid)
{
/* Child. */
if (! pid)
{
/* Child. */
- close (
to_out_fd
);
- close (f
rom_in_fd
);
- dup2 (
to_in_fd
, STDIN_FILENO);
- close (
to_in_fd
);
- dup2 (
from_out_fd
, STDOUT_FILENO);
- close (
from_out_fd
);
+ close (
fd[0]
);
+ close (f
d[1]
);
+ dup2 (
child_fd[0]
, STDIN_FILENO);
+ close (
child_fd[0]
);
+ dup2 (
child_fd[1]
, STDOUT_FILENO);
+ close (
child_fd[1]
);
/* The cast to (char **) rather than (char * const *) is needed
for portability to older hosts with a nonstandard prototype
/* The cast to (char **) rather than (char * const *) is needed
for portability to older hosts with a nonstandard prototype
@@
-144,8
+134,8
@@
create_subpipe (char const * const *argv, int fd[2])
}
/* Parent. */
}
/* Parent. */
- close (
pipe
_fd[0]);
- close (
pipe
_fd[1]);
+ close (
child
_fd[0]);
+ close (
child
_fd[1]);
return pid;
}
return pid;
}