X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fsystem.c;h=bf8e0500ef55c090c7f514625cfe1fd467ab276c;hb=35bb3557343bd4c19399ff8b142a999c3dc18cb6;hp=b1783b1ac2ecca05280f267752ee25d05be8b011;hpb=fa63755f6bf50d67c4403a709a4ff5d02ad23ef3;p=chaz%2Ftar diff --git a/src/system.c b/src/system.c index b1783b1..bf8e050 100644 --- a/src/system.c +++ b/src/system.c @@ -714,34 +714,19 @@ sys_exec_command (char *file_name, int typechar, struct tar_stat_info *st) int p[2]; char *argv[4]; - if (pipe (p)) - { - pipe_error (file_name); - return -1; - } - + xpipe (p); pipe_handler = signal (SIGPIPE, SIG_IGN); - pid = fork (); - - if (pid < 0) - { - fork_error (file_name); - close (p[1]); - close (p[0]); - signal (SIGPIPE, pipe_handler); - return -1; - } + pid = xfork (); if (pid != 0) { - close (p[0]); - return p[1]; + xclose (p[PREAD]); + return p[PWRITE]; } /* Child */ - close (0); - dup (p[0]); - close (p[1]); + xdup2 (p[PREAD], STDIN_FILENO); + xclose (p[PWRITE]); stat_to_env (file_name, typechar, st); @@ -752,8 +737,7 @@ sys_exec_command (char *file_name, int typechar, struct tar_stat_info *st) execv ("/bin/sh", argv); - exec_error (file_name); - _exit (127); + exec_fatal (file_name); } void @@ -786,7 +770,7 @@ sys_wait_command (void) } else ERROR ((0, 0, _("%lu: Child terminated on unknown reason"), - (unsigned long) pid, WTERMSIG (status))); + (unsigned long) pid)); pid = -1; }