1
1

* utilunix.c (mc_doublepopen): Use _exit() instead of exit()

and don't close any unrelated file descriptors.  Explicitly
close inhandle.
Этот коммит содержится в:
Pavel Roskin 2001-07-16 23:34:56 +00:00
родитель b2c12031c0
Коммит f952acf1f8
2 изменённых файлов: 12 добавлений и 7 удалений

Просмотреть файл

@ -1,3 +1,9 @@
2001-07-16 Pavel Roskin <proski@gnu.org>
* utilunix.c (mc_doublepopen): Use _exit() instead of exit()
and don't close any unrelated file descriptors. Explicitly
close inhandle.
2001-07-15 Pavel Roskin <proski@gnu.org> 2001-07-15 Pavel Roskin <proski@gnu.org>
* mad.h: Include stdio.h to prevent redefining mad_tempnam(). * mad.h: Include stdio.h to prevent redefining mad_tempnam().

Просмотреть файл

@ -460,7 +460,6 @@ int mc_doublepopen (int inhandle, int inlen, pid_t *the_pid, char *command, ...)
pid_t pid; pid_t pid;
#define closepipes() close(pipe0[0]);close(pipe0[1]);close(pipe1[0]);close(pipe1[1]) #define closepipes() close(pipe0[0]);close(pipe0[1]);close(pipe1[0]);close(pipe1[1])
#define is_a_pipe_fd(f) ((pipe0[0] == f) || (pipe0[1] == f) || (pipe1[0] == f) || (pipe1[1] == f))
pipe (pipe0); pipe (pipe1); pipe (pipe0); pipe (pipe1);
ignore.sa_handler = SIG_IGN; ignore.sa_handler = SIG_IGN;
@ -481,7 +480,7 @@ int mc_doublepopen (int inhandle, int inlen, pid_t *the_pid, char *command, ...)
switch (pid = fork ()) { switch (pid = fork ()) {
case -1: case -1:
closepipes (); closepipes ();
exit (1); _exit (1);
case 0: { case 0: {
#define MAXARGS 16 #define MAXARGS 16
int argno; int argno;
@ -489,8 +488,6 @@ int mc_doublepopen (int inhandle, int inlen, pid_t *the_pid, char *command, ...)
va_list ap; va_list ap;
int nulldevice; int nulldevice;
port_shutdown_extra_fds ();
nulldevice = open ("/dev/null", O_WRONLY); nulldevice = open ("/dev/null", O_WRONLY);
close (0); close (0);
dup (pipe0 [0]); dup (pipe0 [0]);
@ -509,7 +506,9 @@ int mc_doublepopen (int inhandle, int inlen, pid_t *the_pid, char *command, ...)
} }
va_end (ap); va_end (ap);
execvp (command, args); execvp (command, args);
exit (0);
/* If we are here exec has failed */
_exit (0);
} }
default: default:
{ {
@ -529,13 +528,13 @@ int mc_doublepopen (int inhandle, int inlen, pid_t *the_pid, char *command, ...)
break; break;
} }
} }
close (inhandle);
close (pipe0 [1]); close (pipe0 [1]);
while (waitpid (pid, &i, 0) < 0) while (waitpid (pid, &i, 0) < 0)
if (errno != EINTR) if (errno != EINTR)
break; break;
port_shutdown_extra_fds (); _exit (i);
exit (i);
} }
} }
} }