From 9c097435ba898e6c3a914f56fd6ea07731cbde61 Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Wed, 31 Jan 2007 23:12:06 -0500 Subject: [PATCH] Patch-ID: bash32-015 Bug-Reported-by: Bug-Reference-ID: Bug-Reference-URL: Bug-Description: Under certain circumstances, when using FIFOs for process substitution, bash fails to unlink the FIFOs. This leaves open file descriptors that can cause the shell to hang and litters the file system. This patch, in file bash32-015, was downloaded from ftp.gnu.org on 2011-05-29, and bash32-015.sig was furthermore verified, yielding the following output: gpg: Signature made Mon 19 Mar 2007 10:28:59 AM EDT using DSA key ID 64EA74AB gpg: Good signature from "Chet Ramey " --- execute_cmd.c | 5 +++++ patchlevel.h | 2 +- subst.c | 15 +++++++++++++++ subst.h | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/execute_cmd.c b/execute_cmd.c index 78d36f3..1005bea 100644 --- a/execute_cmd.c +++ b/execute_cmd.c @@ -3050,6 +3050,11 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close) if (command_line == 0) command_line = savestring (the_printed_command_except_trap); +#if defined (PROCESS_SUBSTITUTION) + if ((subshell_environment & SUBSHELL_COMSUB) && (simple_command->flags & CMD_NO_FORK) && fifos_pending() > 0) + simple_command->flags &= ~CMD_NO_FORK; +#endif + execute_disk_command (words, simple_command->redirects, command_line, pipe_in, pipe_out, async, fds_to_close, simple_command->flags); diff --git a/patchlevel.h b/patchlevel.h index 55dca06..4e9afac 100644 --- a/patchlevel.h +++ b/patchlevel.h @@ -25,6 +25,6 @@ regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh looks for to find the patch level (for the sccs version string). */ -#define PATCHLEVEL 14 +#define PATCHLEVEL 15 #endif /* _PATCHLEVEL_H_ */ diff --git a/subst.c b/subst.c index d6ddf92..c60f67a 100644 --- a/subst.c +++ b/subst.c @@ -4143,6 +4143,12 @@ unlink_fifo_list () nfifo = 0; } +int +fifos_pending () +{ + return nfifo; +} + static char * make_named_pipe () { @@ -4192,6 +4198,12 @@ add_fifo_list (fd) nfds++; } +int +fifos_pending () +{ + return 0; /* used for cleanup; not needed with /dev/fd */ +} + void unlink_fifo_list () { @@ -4693,6 +4705,9 @@ command_substitute (string, quoted) last_command_exit_value = rc; rc = run_exit_trap (); +#if defined (PROCESS_SUBSTITUTION) + unlink_fifo_list (); +#endif exit (rc); } else diff --git a/subst.h b/subst.h index 9bc6e2b..477c8fd 100644 --- a/subst.h +++ b/subst.h @@ -222,6 +222,7 @@ extern WORD_LIST *expand_words_shellexp __P((WORD_LIST *)); extern char *command_substitute __P((char *, int)); extern char *pat_subst __P((char *, char *, char *, int)); +extern int fifos_pending __P((void)); extern void unlink_fifo_list __P((void)); extern WORD_LIST *list_string_with_quotes __P((char *)); -- 2.11.4.GIT