pid = fork ();
if (pid == -1) {
perror ("fork");
+ close (so_fd[0]);
+ close (so_fd[1]);
+ close (se_fd[0]);
+ close (se_fd[1]);
return -1;
}
r = select (MAX (so_fd[0], se_fd[0]) + 1, &rset2, NULL, NULL, NULL);
if (r == -1) {
perror ("select");
+ close (so_fd[0]);
+ close (se_fd[0]);
waitpid (pid, NULL, 0);
return -1;
}
r = read (so_fd[0], buf, sizeof buf);
if (r == -1) {
perror ("read");
+ close (so_fd[0]);
+ close (se_fd[0]);
waitpid (pid, NULL, 0);
return -1;
}
r = read (se_fd[0], buf, sizeof buf);
if (r == -1) {
perror ("read");
+ close (so_fd[0]);
+ close (se_fd[0]);
waitpid (pid, NULL, 0);
return -1;
}
}
}
+ close (so_fd[0]);
+ close (se_fd[0]);
+
/* Make sure the output buffers are \0-terminated. Also remove any
* trailing \n characters from the error buffer (not from stdout).
*/