- if (pipe (pipe_fd) != 0)
- error (EXIT_FAILURE, errno, "pipe");
- to_in_fd = pipe_fd[0];
- to_out_fd = pipe_fd[1];
-
- if (pipe (pipe_fd) != 0)
- error (EXIT_FAILURE, errno, "pipe");
- from_in_fd = pipe_fd[0];
- from_out_fd = pipe_fd[1];
+ 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");