Close dead descriptors.

This commit is contained in:
n-a-c-h
2006-03-08 02:11:57 +00:00
parent d34b5a1e44
commit 94b0a5771a

View File

@@ -46,6 +46,7 @@ FILE *safe_popen(char *command, const char *mode)
{
fd_original = dup(STDOUT_FILENO);
dup2(filedes[WRITE_FD], STDOUT_FILENO);
close(filedes[WRITE_FD]);
if (!(fp = fdopen(filedes[READ_FD], mode)))
{
close(filedes[READ_FD]);
@@ -55,6 +56,7 @@ FILE *safe_popen(char *command, const char *mode)
{
fd_original = dup(STDIN_FILENO);
dup2(filedes[READ_FD], STDIN_FILENO);
close(filedes[READ_FD]);
if (!(fp = fdopen(filedes[WRITE_FD], mode)))
{
close(filedes[WRITE_FD]);