mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-29 16:39:53 +02:00
commit bash-20190531 snapshot
This commit is contained in:
@@ -6010,3 +6010,22 @@ lib/readline/bind.c
|
||||
avoid problems with compilers that destroy and recreate it every
|
||||
time through the loop. Report and fix from Adam Richter
|
||||
<adamrichter4@gmail.com>
|
||||
|
||||
5/30
|
||||
----
|
||||
jobs.c
|
||||
- wait_for_job: now takes an additional struct procstat * argument,
|
||||
and returns the pid and status of the job's `controlling process'
|
||||
to the caller
|
||||
|
||||
{jobs,nojobs}.c
|
||||
- wait_for_background_pids: take a struct proctstat * argument and fill
|
||||
it in with pid and status of the last process to terminate
|
||||
|
||||
jobs.h
|
||||
- wait_for_job, wait_for_background_pids: add additional argument to
|
||||
declaration
|
||||
|
||||
builtins/wait.def
|
||||
- wait_builtin: set pstat.{pid,status} each time through the pid-or-job
|
||||
loop and for wait without arguments
|
||||
|
||||
+2
-2
@@ -1247,7 +1247,7 @@ bash_kill_shellword (count, key)
|
||||
rl_kill_text (p, rl_point);
|
||||
|
||||
rl_point = p;
|
||||
if (rl_editing_mode == 1) /* 1 == emacs_mode */
|
||||
if (rl_editing_mode == EMACS_EDITING_MODE) /* 1 == emacs_mode */
|
||||
rl_mark = rl_point;
|
||||
|
||||
return 0;
|
||||
@@ -1268,7 +1268,7 @@ bash_backward_kill_shellword (count, key)
|
||||
if (rl_point != p)
|
||||
rl_kill_text (p, rl_point);
|
||||
|
||||
if (rl_editing_mode == 1) /* 1 == emacs_mode */
|
||||
if (rl_editing_mode == EMACS_EDITING_MODE) /* 1 == emacs_mode */
|
||||
rl_mark = rl_point;
|
||||
|
||||
return 0;
|
||||
|
||||
+11
-5
@@ -1,7 +1,7 @@
|
||||
This file is wait.def, from which is created wait.c.
|
||||
It implements the builtin "wait" in Bash.
|
||||
|
||||
Copyright (C) 1987-2017 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2019 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -102,9 +102,7 @@ wait_builtin (list)
|
||||
{
|
||||
int status, code, opt, nflag, wflags;
|
||||
volatile int old_interrupt_immediately;
|
||||
#if defined (JOB_CONTROL)
|
||||
struct procstat pstat;
|
||||
#endif
|
||||
|
||||
USE_VAR(list);
|
||||
|
||||
@@ -171,7 +169,7 @@ wait_builtin (list)
|
||||
currently active background processes. */
|
||||
if (list == 0)
|
||||
{
|
||||
wait_for_background_pids ();
|
||||
wait_for_background_pids (&pstat);
|
||||
WAIT_RETURN (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -189,10 +187,14 @@ wait_builtin (list)
|
||||
{
|
||||
pid = (pid_t)pid_value;
|
||||
status = wait_for_single_pid (pid, wflags|JWAIT_PERROR);
|
||||
pstat.pid = pid;
|
||||
pstat.status = status;
|
||||
}
|
||||
else
|
||||
{
|
||||
sh_badpid (w);
|
||||
pstat.pid = NO_PID;
|
||||
pstat.status = 127;
|
||||
WAIT_RETURN (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
@@ -212,18 +214,22 @@ wait_builtin (list)
|
||||
sh_badjob (list->word->word);
|
||||
UNBLOCK_CHILD (oset);
|
||||
status = 127; /* As per Posix.2, section 4.70.2 */
|
||||
pstat.pid = NO_PID;
|
||||
pstat.status = status;
|
||||
list = list->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Job spec used. Wait for the last pid in the pipeline. */
|
||||
UNBLOCK_CHILD (oset);
|
||||
status = wait_for_job (job, wflags);
|
||||
status = wait_for_job (job, wflags, &pstat);
|
||||
}
|
||||
#endif /* JOB_CONTROL */
|
||||
else
|
||||
{
|
||||
sh_badpid (w);
|
||||
pstat.pid = NO_PID;
|
||||
pstat.status = 127;
|
||||
status = EXECUTION_FAILURE;
|
||||
}
|
||||
list = list->next;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Simple makefile for the sample loadable builtins
|
||||
#
|
||||
# Copyright (C) 1996-2015 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2019 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -102,8 +102,8 @@ INC = -I. -I.. -I$(topdir) -I$(topdir)/lib -I$(topdir)/builtins -I${srcdir} \
|
||||
|
||||
ALLPROG = print truefalse sleep finfo logname basename dirname fdflags \
|
||||
tty pathchk tee head mkdir rmdir mktemp printenv id whoami \
|
||||
uname sync push ln unlink realpath strftime mypid setpgid seq
|
||||
OTHERPROG = necho hello cat pushd stat rm
|
||||
uname sync push ln unlink realpath strftime mypid setpgid seq rm
|
||||
OTHERPROG = necho hello cat pushd stat
|
||||
|
||||
all: $(SHOBJ_STATUS)
|
||||
|
||||
|
||||
@@ -145,8 +145,12 @@ rm_builtin (list)
|
||||
|
||||
if (list == 0)
|
||||
{
|
||||
builtin_usage ();
|
||||
return (EXECUTION_FAILURE);
|
||||
if (force == 0)
|
||||
{
|
||||
builtin_usage ();
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
for (l = list; l; l = l->next)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/* This file works with both POSIX and BSD systems. It implements job
|
||||
control. */
|
||||
|
||||
/* Copyright (C) 1989-2017 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1989-2019 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -2442,7 +2442,8 @@ wait_for_single_pid (pid, flags)
|
||||
|
||||
/* Wait for all of the background processes started by this shell to finish. */
|
||||
void
|
||||
wait_for_background_pids ()
|
||||
wait_for_background_pids (ps)
|
||||
struct procstat *ps;
|
||||
{
|
||||
register int i, r;
|
||||
int any_stopped, check_async;
|
||||
@@ -2484,6 +2485,11 @@ wait_for_background_pids ()
|
||||
QUIT;
|
||||
errno = 0; /* XXX */
|
||||
r = wait_for_single_pid (pid, JWAIT_PERROR);
|
||||
if (ps)
|
||||
{
|
||||
ps->pid = pid;
|
||||
ps->status = (r < 0) ? 127 : r;
|
||||
}
|
||||
if (r == -1 && errno == ECHILD)
|
||||
{
|
||||
/* If we're mistaken about job state, compensate. */
|
||||
@@ -3049,8 +3055,9 @@ wait_for_return:
|
||||
includes JWAIT_FORCE, we wait for the job to terminate, no just change
|
||||
state */
|
||||
int
|
||||
wait_for_job (job, flags)
|
||||
wait_for_job (job, flags, ps)
|
||||
int job, flags;
|
||||
struct procstat *ps;
|
||||
{
|
||||
pid_t pid;
|
||||
int r, state;
|
||||
@@ -3086,6 +3093,11 @@ wait_for_job (job, flags)
|
||||
jobs[job]->flags |= J_NOTIFIED;
|
||||
UNBLOCK_CHILD (oset);
|
||||
|
||||
if (ps)
|
||||
{
|
||||
ps->pid = pid;
|
||||
ps->status = (r < 0) ? 127 : r;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
@@ -248,9 +248,9 @@ extern int job_exit_status __P((int));
|
||||
extern int job_exit_signal __P((int));
|
||||
|
||||
extern int wait_for_single_pid __P((pid_t, int));
|
||||
extern void wait_for_background_pids __P((void));
|
||||
extern void wait_for_background_pids __P((struct procstat *));
|
||||
extern int wait_for __P((pid_t));
|
||||
extern int wait_for_job __P((int, int));
|
||||
extern int wait_for_job __P((int, int, struct procstat *));
|
||||
extern int wait_for_any_job __P((int, struct procstat *));
|
||||
|
||||
extern void wait_sigint_cleanup __P((void));
|
||||
|
||||
@@ -698,7 +698,8 @@ wait_for_single_pid (pid, flags)
|
||||
/* Wait for all of the shell's children to exit. Called by the `wait'
|
||||
builtin. */
|
||||
void
|
||||
wait_for_background_pids ()
|
||||
wait_for_background_pids (ps)
|
||||
struct procstat *ps;
|
||||
{
|
||||
pid_t got_pid;
|
||||
WAIT status;
|
||||
@@ -712,7 +713,14 @@ wait_for_background_pids ()
|
||||
|
||||
/* Wait for ECHILD */
|
||||
while ((got_pid = WAITPID (-1, &status, 0)) != -1)
|
||||
set_pid_status (got_pid, status);
|
||||
{
|
||||
set_pid_status (got_pid, status);
|
||||
if (ps)
|
||||
{
|
||||
ps->pid = got_pid;
|
||||
ps->status = process_exit_status (status);
|
||||
}
|
||||
}
|
||||
|
||||
if (errno != EINTR && errno != ECHILD)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user