commit bash-20171205 snapshot

This commit is contained in:
Chet Ramey
2017-12-08 07:43:45 -05:00
parent 564452a3ec
commit 1126b09632
7 changed files with 100 additions and 12 deletions
-4
View File
@@ -14545,7 +14545,3 @@ execute_cmd.c
and a status and mark the coproc as dead and having been reaped
with that status. Used by child processes who want to invalidate
the coproc's pid
- coproc_closeall,cpl_closeall: call coproc_setstatus (to invalidate
pid) after closing a coproc (invalidating FDs). Fixes issue with
spurious warning reported by Tobias Hoffmann
<lfile-list@thax.hardliners.org>
+1 -5
View File
@@ -1848,10 +1848,7 @@ cpl_closeall ()
struct cpelement *cpe;
for (cpe = coproc_list.head; cpe; cpe = cpe->next)
{
coproc_close (cpe->coproc);
coproc_setstatus (cpe->coproc, 0); /* fake zero status */
}
coproc_close (cpe->coproc);
}
static void
@@ -2052,7 +2049,6 @@ coproc_closeall ()
cpl_closeall ();
#else
coproc_close (&sh_coproc); /* XXX - will require changes for multiple coprocs */
coproc_setstatus (&sh_coproc, 0); /* fake zero status */
#endif
}
+8
View File
@@ -3536,6 +3536,7 @@ waitchld (wpid, block)
WAIT status;
PROCESS *child;
pid_t pid;
int ind;
int call_set_current, last_stopped_job, job, children_exited, waitpid_flags;
static int wcontinued = WCONTINUED; /* run-time fix for glibc problem */
@@ -3642,6 +3643,13 @@ itrace("waitchld: waitpid returns %d block = %d children_exited = %d", pid, bloc
coproc_pidchk (pid, WSTATUS(status));
#endif
#if defined (PROCESS_SUBSTITUTION)
if ((ind = find_procsub_child (pid)) >= 0)
set_procsub_status (ind, pid, WSTATUS (status));
/* XXX - save in bgpids list? */
#endif
/* It is not an error to have a child terminate that we did
not have a record of. This child could have been part of
a pipeline in backquote substitution. Even so, I'm not
+6
View File
@@ -269,6 +269,12 @@ set_pid_status (pid, status)
coproc_pidchk (pid, status);
#endif
#if defined (PROCESS_SUBSTITUTION)
if ((ind = find_procsub_child (pid)) >= 0)
set_procsub_status (ind, pid, WSTATUS (status));
/* XXX - also saving in list below */
#endif
slot = find_index_by_pid (pid);
if (slot == NO_PID)
return;
+79 -2
View File
@@ -5365,6 +5365,43 @@ close_new_fifos (list, lsize)
unlink_fifo (i);
}
int
find_procsub_child (pid)
pid_t pid;
{
int i;
for (i = 0; i < nfifo; i++)
if ((fifo_list[i].proc == pid)
return i;
return -1;
}
void
set_procsub_status (ind, pid, status)
int ind;
pid_t pid;
int status;
{
if (ind >= 0 && ind < nfifo)
fifo_list[ind].proc = -2; /* sentinel */
}
/* If we've marked the process for this procsub as dead, close the
associated file descriptor and delete the FIFO. */
void
reap_procsubs ()
{
int i;
for (i = 0; i < nfifo; i++)
if (fifo_list[i].proc == -2) /* reaped */
{
fifo_list[i].proc = -1;
unlink_fifo (ind);
}
}
int
fifos_pending ()
{
@@ -5502,7 +5539,7 @@ unlink_fifo_list ()
if (nfds == 0)
return;
for (i = 0; nfds && i < totfds; i++)
for (i = totfds-1; nfds && i >= 0; i--)
unlink_fifo (i);
nfds = 0;
@@ -5534,6 +5571,44 @@ close_new_fifos (list, lsize)
unlink_fifo (i);
}
int
find_procsub_child (pid)
pid_t pid;
{
int i;
if (nfds == 0)
return -1;
for (i = 0; i < totfds; i++)
if (dev_fd_list[i] == pid)
return i;
return -1;
}
void
set_procsub_status (ind, pid, status)
int ind;
pid_t pid;
int status;
{
if (ind >= 0 && ind < totfds)
dev_fd_list[ind] = -2; /* sentinel */
}
/* If we've marked the process for this procsub as dead, close the
associated file descriptor. */
void
reap_procsubs ()
{
int i;
for (i = 0; nfds > 0 && i < totfds; i++)
if (dev_fd_list[i] == -2)
unlink_fifo (i);
}
#if defined (NOTDEF)
print_dev_fd_list ()
{
@@ -5687,7 +5762,9 @@ process_substitute (string, open_for_read_in_child)
last_procsub_child = restore_pipeline (0);
#endif
#if !defined (HAVE_DEV_FD)
#if defined (HAVE_DEV_FD)
dev_fd_list[parent_pipe_fd] = pid;
#else
fifo_list[nfifo-1].proc = pid;
#endif
+5
View File
@@ -265,6 +265,7 @@ extern WORD_LIST *expand_words_shellexp __P((WORD_LIST *));
extern WORD_DESC *command_substitute __P((char *, int, int));
extern char *pat_subst __P((char *, char *, char *, int));
#if defined (PROCESS_SUBSTITUTION)
extern int fifos_pending __P((void));
extern int num_fifos __P((void));
extern void unlink_fifo_list __P((void));
@@ -276,6 +277,10 @@ extern void close_new_fifos __P((char *, int));
extern void clear_fifo_list __P((void));
extern int find_procsub_child __P((pid_t));
extern void set_procsub_status __P((int, pid_t, int));
#endif
extern WORD_LIST *list_string_with_quotes __P((char *));
#if defined (ARRAY_VARS)
+1 -1
View File
@@ -1,4 +1,4 @@
BUILD_DIR=/usr/local/build/chet/bash/bash-current
BUILD_DIR=/usr/local/build/bash/bash-current
THIS_SH=$BUILD_DIR/bash
PATH=$PATH:$BUILD_DIR