Update to latest upstream release: Zsh 5.0.8

This commit is contained in:
Kamil Dudka 2015-06-01 13:51:46 +02:00
parent 724b3efd39
commit b84eb4bacc
12 changed files with 39 additions and 860 deletions

11
.gitignore vendored
View File

@ -1,10 +1 @@
zsh-4.3.11.tar.bz2 /zsh-5.*.*.tar.bz2
/zsh-4.3.13.tar.bz2
/zsh-4.3.14.tar.bz2
/zsh-4.3.15.tar.bz2
/zsh-4.3.17.tar.bz2
/zsh-5.0.0.tar.bz2
/zsh-5.0.2.tar.bz2
/zsh-5.0.5.tar.bz2
/zsh-5.0.6.tar.bz2
/zsh-5.0.7.tar.bz2

View File

@ -1 +1 @@
1cd396ce17952de50b8a89980d617f0a zsh-5.0.7.tar.bz2 e6759e8dd7b714d624feffd0a73ba0fe zsh-5.0.8.tar.bz2

View File

@ -1,87 +0,0 @@
From 19c75aec6843b827fa7ef3f39174090ee7f8ac18 Mon Sep 17 00:00:00 2001
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
Date: Thu, 22 Jan 2015 20:20:15 +0000
Subject: [PATCH 1/2] 34331: better handling of NULL in cd.
Problem was return from symbolic link expander in weird cases
where there file system isn't behaving itself properly.
Upstream-commit: 12b813b5895cae579e403dafe43878868f27fe0f
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
Src/builtin.c | 8 +++++---
Src/utils.c | 11 +++++++----
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/Src/builtin.c b/Src/builtin.c
index 2118835..489ca23 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -1156,9 +1156,11 @@ cd_new_pwd(int func, LinkNode dir, int quiet)
zsfree(getlinknode(dirstack));
if (chasinglinks) {
- s = new_pwd;
- new_pwd = findpwd(s);
- zsfree(s);
+ s = findpwd(new_pwd);
+ if (s) {
+ zsfree(new_pwd);
+ new_pwd = s;
+ }
}
if (isset(PUSHDIGNOREDUPS)) {
LinkNode n;
diff --git a/Src/utils.c b/Src/utils.c
index e6eb8e6..80396a2 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -1049,10 +1049,13 @@ getnameddir(char *name)
if ((pw = getpwnam(name))) {
char *dir = isset(CHASELINKS) ? xsymlink(pw->pw_dir)
: ztrdup(pw->pw_dir);
- adduserdir(name, dir, ND_USERNAME, 1);
- str = dupstring(dir);
- zsfree(dir);
- return str;
+ if (dir) {
+ adduserdir(name, dir, ND_USERNAME, 1);
+ str = dupstring(dir);
+ zsfree(dir);
+ return str;
+ } else
+ return ztrdup(pw->pw_dir);
}
}
#endif /* HAVE_GETPWNAM */
--
2.1.0
From d0777e66d47d0a87f3171962d8137a6cb75d7ade Mon Sep 17 00:00:00 2001
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
Date: Sun, 25 Jan 2015 18:03:20 +0000
Subject: [PATCH 2/2] 34383: ztrdup() should be dupstring() in new cd code
Upstream-commit: ccd3663d4e9a1749450b35cc689359f78a310c04
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
Src/utils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Src/utils.c b/Src/utils.c
index 80396a2..ef71210 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -1055,7 +1055,7 @@ getnameddir(char *name)
zsfree(dir);
return str;
} else
- return ztrdup(pw->pw_dir);
+ return dupstring(pw->pw_dir);
}
}
#endif /* HAVE_GETPWNAM */
--
2.1.0

View File

@ -1,97 +0,0 @@
From dc0675a5b8f89b8e504fe1641d57a896674caac5 Mon Sep 17 00:00:00 2001
From: Peter Stephenson <pws@zsh.org>
Date: Tue, 20 Jan 2015 09:29:22 +0000
Subject: [PATCH 1/2] users/19751: remove error on failure to close file
descriptor by number.
Keep it when closing file descriptor stored in a variable, i.e.
explicitly opened by the user.
Upstream-commit: e6d964246700581fe22ea834b2ea12dd301e8c3d
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
Src/exec.c | 7 ++++++-
Test/A04redirect.ztst | 10 ++++++----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/Src/exec.c b/Src/exec.c
index a9c4688..04c8b50 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3167,7 +3167,12 @@ execcmd(Estate state, int input, int output, int how, int last1)
}
if (fn->fd1 < 10)
closemn(mfds, fn->fd1, REDIR_CLOSE);
- if (!closed && zclose(fn->fd1) < 0) {
+ /*
+ * Only report failures to close file descriptors
+ * if they're under user control as we don't know
+ * what the previous status of others was.
+ */
+ if (!closed && zclose(fn->fd1) < 0 && fn->varid) {
zwarn("failed to close file descriptor %d: %e",
fn->fd1, errno);
}
diff --git a/Test/A04redirect.ztst b/Test/A04redirect.ztst
index a39ce46..cb67788 100644
--- a/Test/A04redirect.ztst
+++ b/Test/A04redirect.ztst
@@ -152,11 +152,13 @@
>hello
>goodbye
- ({ exec 3<&- } 2>/dev/null
- exec 3<&-
- read foo <&-)
+ (exec {varid}<&0
+ exec {varid}<&-
+ print About to close a second time >&2
+ read {varid}<&-)
1:'<&-' redirection
-*?\(eval\):*: failed to close file descriptor 3:*
+?About to close a second time
+*?\(eval\):*: failed to close file descriptor *
print foo >&-
0:'>&-' redirection
--
2.1.0
From 206fdc852a0f28dddce7411eafeb3ab29b0259ed Mon Sep 17 00:00:00 2001
From: Peter Stephenson <pws@zsh.org>
Date: Tue, 20 Jan 2015 11:53:42 +0000
Subject: [PATCH 2/2] users/19756: test for case of closing fd with no error
message
Upstream-commit: 638bfa93a009987e57bd7eaa8b2a1c1067a3652a
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
Test/A04redirect.ztst | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/Test/A04redirect.ztst b/Test/A04redirect.ztst
index cb67788..13f1f7c 100644
--- a/Test/A04redirect.ztst
+++ b/Test/A04redirect.ztst
@@ -152,11 +152,16 @@
>hello
>goodbye
+ ({exec 3<&- } 2>/dev/null
+ exec 3<&-
+ read foo <&-)
+1:'<&-' redirection with numeric fd (no error message on failure)
+
(exec {varid}<&0
exec {varid}<&-
print About to close a second time >&2
read {varid}<&-)
-1:'<&-' redirection
+1:'<&-' redirection with fd in variable (error message on failure)
?About to close a second time
*?\(eval\):*: failed to close file descriptor *
--
2.1.0

View File

@ -1,28 +0,0 @@
From 9b948be0afaa3ab0dee1e04edd2b577cf4010290 Mon Sep 17 00:00:00 2001
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
Date: Fri, 17 Apr 2015 22:43:38 +0100
Subject: [PATCH] 34921: handle error in recursive par_event().
Here documents in an interrupted list caused bad juju.
Upstream-commit: 2e48eceb1ad2b7b33170d7104e94351cc7231e51
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
Src/parse.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/parse.c b/Src/parse.c
index 433efb9..30270ef 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -515,6 +515,7 @@ par_event(void)
if (!par_event()) {
ecused = oec;
ecbuf[p] |= wc_bdata(Z_END);
+ return errflag ? 0 : 1;
}
}
return 1;
--
2.1.0

View File

@ -1,45 +0,0 @@
From 3427fe59c2d76ddbf4b23908c6ae5272734c7c8b Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer" <schaefer@zsh.org>
Date: Wed, 20 May 2015 10:14:04 -0700
Subject: [PATCH] 35231: make mkevnstr() safe for NULL value
Upstream-commit: af957f2ed6287f66953742fbca69188cecb98fbf
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
Src/params.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/Src/params.c b/Src/params.c
index 61edc5d..d0ce0a9 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -4534,17 +4534,21 @@ addenv(Param pm, char *value)
static char *
mkenvstr(char *name, char *value, int flags)
{
- char *str, *s;
- int len_name, len_value;
+ char *str, *s = value;
+ int len_name, len_value = 0;
len_name = strlen(name);
- for (len_value = 0, s = value;
- *s && (*s++ != Meta || *s++ != 32); len_value++);
+ if (s)
+ while (*s && (*s++ != Meta || *s++ != 32))
+ len_value++;
s = str = (char *) zalloc(len_name + len_value + 2);
strcpy(s, name);
s += len_name;
*s = '=';
- copyenvstr(s, value, flags);
+ if (value)
+ copyenvstr(s, value, flags);
+ else
+ *++s = '\0';
return str;
}
--
2.4.1

View File

@ -1,42 +0,0 @@
From 9f9b98e0fe83c8aab493369c0671360ed06e138b Mon Sep 17 00:00:00 2001
From: Peter Stephenson <pws@zsh.org>
Date: Thu, 15 Jan 2015 13:50:09 +0000
Subject: [PATCH] 34287: preprocessor for signal name generation.
Some gcc header files are difficult for the signames2.awk
script to process, so if the preprocessor is gcc give the
option -P to strip out the unwanted additions.
Upstream-commit: c7aa6443907ddd97b6b1e8729ce9c897de0d244c
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
Src/zsh.mdd | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/Src/zsh.mdd b/Src/zsh.mdd
index 9a8c923..469e91b 100644
--- a/Src/zsh.mdd
+++ b/Src/zsh.mdd
@@ -21,9 +21,18 @@ hdrdeps="zshcurses.h zshterm.h"
:<<\Make
@CONFIG_MK@
+# If we're using gcc as the preprocessor, get rid of the additional
+# lines generated by the preprocessor as they can confuse the script.
+# We don't need these in other cases either, but can't necessarily rely
+# on the option to remove them being the same.
signames.c: signames1.awk signames2.awk ../config.h @SIGNAL_H@
$(AWK) -f $(sdir)/signames1.awk @SIGNAL_H@ >sigtmp.c
- $(CPP) sigtmp.c >sigtmp.out
+ case "$(CPP)" in \
+ gcc*) \
+ $(CPP) -P sigtmp.c >sigtmp.out;; \
+ *) \
+ $(CPP) sigtmp.c >sigtmp.out;; \
+ esac
$(AWK) -f $(sdir)/signames2.awk sigtmp.out > $@
rm -f sigtmp.c sigtmp.out
--
2.1.0

View File

@ -1,104 +0,0 @@
From 7c9af538d63b4623b38ef2fa9903e0f0344ffc32 Mon Sep 17 00:00:00 2001
From: "Barton E. Schaefer" <schaefer@zsh.org>
Date: Fri, 20 Feb 2015 18:45:36 -0800
Subject: [PATCH] 34590: queue_signals() around more scopes that manipulate
global state
Upstream-commit: a4ff8e69570cbdb8e7d5bf1d5cc4000ffe63e15e
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
Src/exec.c | 4 +++-
Src/text.c | 15 +++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/Src/exec.c b/Src/exec.c
index 04c8b50..b59eb5e 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2320,6 +2320,7 @@ addvars(Estate state, Wordcode pc, int addflags)
void
setunderscore(char *str)
{
+ queue_signals();
if (str && *str) {
int l = strlen(str) + 1, nl = (l + 31) & ~31;
@@ -2337,6 +2338,7 @@ setunderscore(char *str)
*zunderscore = '\0';
underscoreused = 1;
}
+ unqueue_signals();
}
/* These describe the type of expansions that need to be done on the words
@@ -5246,7 +5248,7 @@ execsave(void)
{
struct execstack *es;
- es = (struct execstack *) malloc(sizeof(struct execstack));
+ es = (struct execstack *) zalloc(sizeof(struct execstack));
es->list_pipe_pid = list_pipe_pid;
es->nowait = nowait;
es->pline_level = pline_level;
diff --git a/Src/text.c b/Src/text.c
index f55553e..8f8eb34 100644
--- a/Src/text.c
+++ b/Src/text.c
@@ -173,6 +173,8 @@ getpermtext(Eprog prog, Wordcode c, int start_indent)
{
struct estate s;
+ queue_signals();
+
if (!c)
c = prog->prog;
@@ -193,6 +195,9 @@ getpermtext(Eprog prog, Wordcode c, int start_indent)
*tptr = '\0';
freeeprog(prog); /* mark as unused */
untokenize(tbuf);
+
+ unqueue_signals();
+
return tbuf;
}
@@ -206,6 +211,8 @@ getjobtext(Eprog prog, Wordcode c)
struct estate s;
+ queue_signals();
+
if (!c)
c = prog->prog;
@@ -224,6 +231,9 @@ getjobtext(Eprog prog, Wordcode c)
*tptr = '\0';
freeeprog(prog); /* mark as unused */
untokenize(jbuf);
+
+ unqueue_signals();
+
return jbuf;
}
@@ -879,6 +889,9 @@ getredirs(LinkList redirs)
">", ">|", ">>", ">>|", "&>", "&>|", "&>>", "&>>|", "<>", "<",
"<<", "<<-", "<<<", "<&", ">&", NULL /* >&- */, "<", ">"
};
+
+ queue_signals();
+
taddchr(' ');
for (n = firstnode(redirs); n; incnode(n)) {
Redir f = (Redir) getdata(n);
@@ -966,4 +979,6 @@ getredirs(LinkList redirs)
}
}
tptr--;
+
+ unqueue_signals();
}
--
2.1.0

View File

@ -1,397 +0,0 @@
From 223ac53797d33b0473323efc0d5a44d1dceaf746 Mon Sep 17 00:00:00 2001
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
Date: Sun, 26 Oct 2014 17:47:42 +0000
Subject: [PATCH 1/2] 33531 with additions: retain status of exited background
jobs.
Add linked list of unwaited-for background jobs.
Truncate at value of _SC_CHILD_MAX discarding oldest.
Remove old lastpid_status mechanism for latest exited process only.
Slightly tighten safety of permanently allocated linked lists so
that this doesn't compromise signal handling.
Upstream-commit: b4f7ccecd93ca9e64c3c3c774fdaefae83d7204a
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
Doc/Zsh/builtins.yo | 16 ++++++
Doc/Zsh/options.yo | 8 +--
Doc/zshoptions.1 | 8 +--
Src/exec.c | 2 -
Src/init.c | 1 -
Src/jobs.c | 138 ++++++++++++++++++++++++++++++++++++++++++++--------
Src/linklist.c | 4 ++
Src/signals.c | 14 +++---
8 files changed, 152 insertions(+), 39 deletions(-)
diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 46f40cc..edc335e 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -2059,6 +2059,22 @@ then all currently active child processes are waited for.
Each var(job) can be either a job specification or the process ID
of a job in the job table.
The exit status from this command is that of the job waited for.
+
+It is possible to wait for recent processes (specified by process ID,
+not by job) that were running in the background even if the process has
+exited. Typically the process ID will be recorded by capturing the
+value of the variable tt($!) immediately after the process has been
+started. There is a limit on the number of process IDs remembered by
+the shell; this is given by the value of the system configuration
+parameter tt(CHILD_MAX). When this limit is reached, older process IDs
+are discarded, least recently started processes first.
+
+Note there is no protection against the process ID wrapping, i.e. if the
+wait is not executed soon enough there is a chance the process waited
+for is the wrong one. A conflict implies both process IDs have been
+generated by the shell, as other processes are not recorded, and that
+the user is potentially interested in both, so this problem is intrinsic
+to process IDs.
)
findex(whence)
item(tt(whence) [ tt(-vcwfpams) ] var(name) ...)(
diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo
index 068a253..452b258 100644
--- a/Doc/Zsh/options.yo
+++ b/Doc/Zsh/options.yo
@@ -1434,10 +1434,10 @@ shell is saved for output within a subshell (for example, within a
pipeline). When the option is set, the output of tt(jobs) is empty
until a job is started within the subshell.
-When the option is set, it becomes possible to use the tt(wait) builtin to
-wait for the last job started in the background (as given by tt($!)) even
-if that job has already exited. This works even if the option is turned
-on temporarily around the use of the tt(wait) builtin.
+In previous versions of the shell, it was necessary to enable
+tt(POSIX_JOBS) in order for the builtin command tt(wait) to return the
+status of background jobs that had already exited. This is no longer
+the case.
)
enditem()
diff --git a/Doc/zshoptions.1 b/Doc/zshoptions.1
index cc0bd7e..038e259 100644
--- a/Doc/zshoptions.1
+++ b/Doc/zshoptions.1
@@ -892,10 +892,10 @@ shell is saved for output within a subshell (for example, within a
pipeline)\&. When the option is set, the output of \fBjobs\fP is empty
until a job is started within the subshell\&.
.PP
-When the option is set, it becomes possible to use the \fBwait\fP builtin to
-wait for the last job started in the background (as given by \fB$!\fP) even
-if that job has already exited\&. This works even if the option is turned
-on temporarily around the use of the \fBwait\fP builtin\&.
+In previous versions of the shell, it was necessary to enable
+\fBPOSIX_JOBS\fP in order for the builtin command \fBwait\fP to return the
+status of background jobs that had already exited\&. This is no longer
+the case\&.
.RE
.PP
.SS "Prompting"
diff --git a/Src/exec.c b/Src/exec.c
index d0fadd6..a9c4688 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2941,8 +2941,6 @@ execcmd(Estate state, int input, int output, int how, int last1)
close(synch[0]);
if (how & Z_ASYNC) {
lastpid = (zlong) pid;
- /* indicate it's possible to set status for lastpid */
- lastpid_status = -2L;
} else if (!jobtab[thisjob].stty_in_env && varspc) {
/* search for STTY=... */
Wordcode p = varspc;
diff --git a/Src/init.c b/Src/init.c
index c26d887..6666f98 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -1036,7 +1036,6 @@ setupvals(void)
bufstack = znewlinklist();
hsubl = hsubr = NULL;
lastpid = 0;
- lastpid_status = -1L;
get_usage();
diff --git a/Src/jobs.c b/Src/jobs.c
index bd95afb..18bb648 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -104,15 +104,6 @@ int prev_errflag, prev_breaks, errbrk_saved;
/**/
int numpipestats, pipestats[MAX_PIPESTATS];
-/*
- * The status associated with the process lastpid.
- * -1 if not set and no associated lastpid
- * -2 if lastpid is set and status isn't yet
- * else the value returned by wait().
- */
-/**/
-long lastpid_status;
-
/* Diff two timevals for elapsed-time computations */
/**/
@@ -1309,14 +1300,6 @@ addproc(pid_t pid, char *text, int aux, struct timeval *bgtime)
{
Process pn, *pnlist;
- if (pid == lastpid && lastpid_status != -2L) {
- /*
- * The status for the previous lastpid is invalid.
- * Presumably process numbers have wrapped.
- */
- lastpid_status = -1L;
- }
-
DPUTS(thisjob == -1, "No valid job in addproc.");
pn = (Process) zshcalloc(sizeof *pn);
pn->pid = pid;
@@ -1940,6 +1923,122 @@ maybeshrinkjobtab(void)
unqueue_signals();
}
+/*
+ * Definitions for the background process stuff recorded below.
+ * This would be more efficient as a hash, but
+ * - that's quite heavyweight for something not needed very often
+ * - we need some kind of ordering as POSIX allows us to limit
+ * the size of the list to the value of _SC_CHILD_MAX and clearly
+ * we want to clear the oldest first
+ * - cases with a long list of background jobs where the user doesn't
+ * wait for a large number, and then does wait for one (the only
+ * inefficient case) are rare
+ * - in the context of waiting for an external process, looping
+ * over a list isn't so very inefficient.
+ * Enough excuses already.
+ */
+
+/* Data in the link list, a key (process ID) / value (exit status) pair. */
+struct bgstatus {
+ pid_t pid;
+ int status;
+};
+typedef struct bgstatus *Bgstatus;
+/* The list of those entries */
+LinkList bgstatus_list;
+/* Count of entries. Reaches value of _SC_CHILD_MAX and stops. */
+long bgstatus_count;
+
+/*
+ * Remove and free a bgstatus entry.
+ */
+static void rembgstatus(LinkNode node)
+{
+ zfree(remnode(bgstatus_list, node), sizeof(struct bgstatus));
+ bgstatus_count--;
+}
+
+/*
+ * Record the status of a background process that exited so we
+ * can execute the builtin wait for it.
+ *
+ * We can't execute the wait builtin for something that exited in the
+ * foreground as it's not visible to the user, so don't bother recording.
+ */
+
+/**/
+void
+addbgstatus(pid_t pid, int status)
+{
+ static long child_max;
+ Bgstatus bgstatus_entry;
+
+ if (!child_max) {
+#ifdef _SC_CHILD_MAX
+ child_max = sysconf(_SC_CHILD_MAX);
+ if (!child_max) /* paranoia */
+#endif
+ {
+ /* Be inventive */
+ child_max = 1024L;
+ }
+ }
+
+ if (!bgstatus_list) {
+ bgstatus_list = znewlinklist();
+ /*
+ * We're not always robust about memory failures, but
+ * this is pretty deep in the shell basics to be failing owing
+ * to memory, and a failure to wait is reported loudly, so test
+ * and fail silently here.
+ */
+ if (!bgstatus_list)
+ return;
+ }
+ if (bgstatus_count == child_max) {
+ /* Overflow. List is in order, remove first */
+ rembgstatus(firstnode(bgstatus_list));
+ }
+ bgstatus_entry = (Bgstatus)zalloc(sizeof(*bgstatus_entry));
+ if (!bgstatus_entry) {
+ /* See note above */
+ return;
+ }
+ bgstatus_entry->pid = pid;
+ bgstatus_entry->status = status;
+ if (!zaddlinknode(bgstatus_list, bgstatus_entry)) {
+ zfree(bgstatus_entry, sizeof(*bgstatus_entry));
+ return;
+ }
+ bgstatus_count++;
+}
+
+/*
+ * See if pid has a recorded exit status.
+ * Note we make no guarantee that the PIDs haven't wrapped, so this
+ * may not be the right process.
+ *
+ * This is only used by wait, which must only work on each
+ * pid once, so we need to remove the entry if we find it.
+ */
+
+static int getbgstatus(pid_t pid)
+{
+ LinkNode node;
+ Bgstatus bgstatus_entry;
+
+ if (!bgstatus_list)
+ return -1;
+ for (node = firstnode(bgstatus_list); node; incnode(node)) {
+ bgstatus_entry = (Bgstatus)getdata(node);
+ if (bgstatus_entry->pid == pid) {
+ int status = bgstatus_entry->status;
+ rembgstatus(node);
+ return status;
+ }
+ }
+ return -1;
+}
/* bg, disown, fg, jobs, wait: most of the job control commands are *
* here. They all take the same type of argument. Exception: wait can *
@@ -2085,10 +2184,7 @@ bin_fg(char *name, char **argv, Options ops, int func)
}
if (retval == 0)
retval = lastval2;
- } else if (isset(POSIXJOBS) &&
- pid == lastpid && lastpid_status >= 0L) {
- retval = (int)lastpid_status;
- } else {
+ } else if ((retval = getbgstatus(pid)) < 0) {
zwarnnam(name, "pid %d is not a child of this shell", pid);
/* presumably lastval2 doesn't tell us a heck of a lot? */
retval = 1;
diff --git a/Src/linklist.c b/Src/linklist.c
index 1e364fb..3aa8125 100644
--- a/Src/linklist.c
+++ b/Src/linklist.c
@@ -118,6 +118,8 @@ znewlinklist(void)
LinkList list;
list = (LinkList) zalloc(sizeof *list);
+ if (!list)
+ return NULL;
list->list.first = NULL;
list->list.last = &list->node;
list->list.flags = 0;
@@ -152,6 +154,8 @@ zinsertlinknode(LinkList list, LinkNode node, void *dat)
tmp = node->next;
node->next = new = (LinkNode) zalloc(sizeof *tmp);
+ if (!new)
+ return NULL;
new->prev = node;
new->dat = dat;
new->next = tmp;
diff --git a/Src/signals.c b/Src/signals.c
index 2df69f9..e728505 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -522,14 +522,14 @@ wait_for_processes(void)
get_usage();
}
/*
- * Remember the status associated with $!, so we can
- * wait for it even if it's exited. This value is
- * only used if we can't find the PID in the job table,
- * so it doesn't matter that the value we save here isn't
- * useful until the process has exited.
+ * Accumulate a list of older jobs. We only do this for
+ * background jobs, which is something in the job table
+ * that's not marked as in the current shell or as shell builtin
+ * and is not equal to the current foreground job.
*/
- if (pn != NULL && pid == lastpid && lastpid_status != -1L)
- lastpid_status = lastval2;
+ if (jn && !(jn->stat & (STAT_CURSH|STAT_BUILTIN)) &&
+ jn - jobtab != thisjob)
+ addbgstatus(pid, (int)lastval2);
}
}
--
2.1.0
From 2d59469450ba80b69449dc2777f0fc0673e0fbd6 Mon Sep 17 00:00:00 2001
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
Date: Sun, 26 Oct 2014 19:04:47 +0000
Subject: [PATCH 2/2] 33542: test logic for waiting for already exited
processes
Upstream-commit: 9a551ca85999ff329714fd2cca138ce2f7d3c3d9
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
Test/A05execution.ztst | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
diff --git a/Test/A05execution.ztst b/Test/A05execution.ztst
index ca97f4f..589815f 100644
--- a/Test/A05execution.ztst
+++ b/Test/A05execution.ztst
@@ -190,9 +190,9 @@
print "${pipestatus[@]}")
ZTST_hashmark
done | sort | uniq -c | sed 's/^ *//'
-0:Check whether `$pipestatus[]' behaves.
+0:Check whether '$pipestatus[]' behaves.
>2048 2 1 0
-F:This test checks for a bug in `$pipestatus[]' handling. If it breaks then
+F:This test checks for a bug in '$pipestatus[]' handling. If it breaks then
F:the bug is still there or it reappeared. See workers-29973 for details.
{ setopt MONITOR } 2>/dev/null
@@ -244,3 +244,28 @@ F:anonymous function, and a descriptor leak when backgrounding a pipeline
>autoload_redir () {
> print Autoloaded ksh style
>} > autoload.log
+
+# This tests that we record the status of processes that have already exited
+# for when we wait for them.
+#
+# Actually, we don't guarantee here that the jobs have already exited, but
+# the order of the waits means it's highly likely we do need to recall a
+# previous status, barring accidents which shouldn't happen very often. In
+# other words, we rely on the test working repeatedly rather than just
+# once. The monitor option is irrelevant to the logic, so we'll make
+# our job easier by turning it off.
+ unsetopt monitor
+ (exit 1) &
+ one=$!
+ (exit 2) &
+ two=$!
+ (exit 3) &
+ three=$!
+ wait $three
+ print $?
+ wait $two
+ print $?
+ wait $one
+1:The status of recently exited background jobs is recorded
+>3
+>2
--
2.1.0

View File

@ -1,6 +1,12 @@
--- zsh-4.0.4/Src/builtin.c.open Tue Oct 16 02:49:17 2001 Src/builtin.c | 2 +-
+++ zsh-4.0.4/Src/builtin.c Wed May 15 11:55:32 2002 Src/init.c | 34 ++++++++++++++++++++++++++++++++--
@@ -5262,7 +5262,7 @@ bin_read(char *name, char **args, Options ops, UNUSED(int func)) 2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/Src/builtin.c b/Src/builtin.c
index 9358e8b..ee14f91 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -5411,7 +5411,7 @@ bin_read(char *name, char **args, Options ops, UNUSED(int func))
if (!zleactive) { if (!zleactive) {
if (SHTTY == -1) { if (SHTTY == -1) {
/* need to open /dev/tty specially */ /* need to open /dev/tty specially */
@ -9,9 +15,11 @@
haso = 1; haso = 1;
oshout = shout; oshout = shout;
init_shout(); init_shout();
--- zsh-4.0.4/Src/init.c.open Wed Oct 24 04:16:32 2001 diff --git a/Src/init.c b/Src/init.c
+++ zsh-4.0.4/Src/init.c Wed May 15 12:00:07 2002 index 102276a..238f6ed 100644
@@ -508,7 +508,7 @@ init_io(void) --- a/Src/init.c
+++ b/Src/init.c
@@ -542,7 +542,7 @@ init_io(void)
if (isatty(0)) { if (isatty(0)) {
zsfree(ttystrname); zsfree(ttystrname);
if ((ttystrname = ztrdup(ttyname(0)))) { if ((ttystrname = ztrdup(ttyname(0)))) {
@ -20,7 +28,7 @@
#ifdef TIOCNXCL #ifdef TIOCNXCL
/* /*
* See if the terminal claims to be busy. If so, and fd 0 * See if the terminal claims to be busy. If so, and fd 0
@@ -549,7 +549,7 @@ init_io(void) @@ -583,7 +583,7 @@ init_io(void)
ttystrname = ztrdup(ttyname(1)); ttystrname = ztrdup(ttyname(1));
} }
if (SHTTY == -1 && if (SHTTY == -1 &&
@ -29,7 +37,7 @@
zsfree(ttystrname); zsfree(ttystrname);
ttystrname = ztrdup(ttyname(SHTTY)); ttystrname = ztrdup(ttyname(SHTTY));
} }
@@ -1671,3 +1671,33 @@ zsh_main(UNUSED(int argc), char **argv) @@ -1707,3 +1707,33 @@ zsh_main(UNUSED(int argc), char **argv)
: "use 'logout' to logout."); : "use 'logout' to logout.");
} }
} }

View File

@ -1,7 +1,11 @@
diff -ru zsh-4.3.6-orig/Test/C02cond.ztst zsh-4.3.6/Test/C02cond.ztst Test/C02cond.ztst | 6 ++++--
--- zsh-4.3.6-orig/Test/C02cond.ztst 2008-02-27 06:41:13.000000000 -0500 1 file changed, 4 insertions(+), 2 deletions(-)
+++ zsh-4.3.6/Test/C02cond.ztst 2008-08-25 17:39:13.000000000 -0400
@@ -187,7 +187,8 @@ diff --git a/Test/C02cond.ztst b/Test/C02cond.ztst
index 02fa4d4..97f679c 100644
--- a/Test/C02cond.ztst
+++ b/Test/C02cond.ztst
@@ -204,7 +204,8 @@ F:Failures in these cases do not indicate a problem in the shell.
print -u$ZTST_fd "Warning: not testing [[ -e /dev/fd/0 ]] (/dev/fd not supported)" print -u$ZTST_fd "Warning: not testing [[ -e /dev/fd/0 ]] (/dev/fd not supported)"
true true
else else
@ -11,7 +15,7 @@ diff -ru zsh-4.3.6-orig/Test/C02cond.ztst zsh-4.3.6/Test/C02cond.ztst
fi fi
0dD:/dev/fd support in conds handled by access 0dD:/dev/fd support in conds handled by access
@@ -195,7 +196,8 @@ @@ -212,7 +213,8 @@ F:Failures in these cases do not indicate a problem in the shell.
print -u$ZTST_fd "Warning: not testing [[ -O /dev/fd/0 ]] (/dev/fd not supported)" print -u$ZTST_fd "Warning: not testing [[ -O /dev/fd/0 ]] (/dev/fd not supported)"
true true
else else

View File

@ -2,8 +2,8 @@
Summary: Powerful interactive shell Summary: Powerful interactive shell
Name: zsh Name: zsh
Version: 5.0.7 Version: 5.0.8
Release: 8%{?dist} Release: 1%{?dist}
License: MIT License: MIT
URL: http://zsh.sourceforge.net/ URL: http://zsh.sourceforge.net/
Group: System Environment/Shells Group: System Environment/Shells
@ -15,31 +15,11 @@ Source4: zshrc.rhs
Source5: zshenv.rhs Source5: zshenv.rhs
Source6: dotzshrc Source6: dotzshrc
Source7: zshprompt.pl Source7: zshprompt.pl
# legacy downstream patches, TODO: either get them upstream or drop them
Patch0: zsh-serial.patch Patch0: zsh-serial.patch
Patch1: zsh-4.3.6-8bit-prompts.patch
Patch4: zsh-4.3.6-8bit-prompts.patch Patch2: zsh-test-C02-dev_fd-mock.patch
Patch5: zsh-test-C02-dev_fd-mock.patch
# make the wait built-in work for already exited processes (#1162198)
Patch6: zsh-5.0.7-wait-for-exited.patch
# suppress a warning about closing an already closed file descriptor (#1184002)
Patch7: zsh-5.0.7-close-fd.patch
# improve handling of NULL in the 'cd' built-in (#1183238)
Patch8: zsh-5.0.7-cd-sigsegv.patch
# fix SIGSEGV when handling heredocs and keyboard interrupt (#972624)
Patch9: zsh-5.0.7-heredocs-sigsegv.patch
# queue signals when manipulating global state to avoid deadlock
Patch10: zsh-5.0.7-signal-safety.patch
# improve signal name generation (prevents Test/C03traps.ztst from failing)
Patch11: zsh-5.0.7-signal-name.patch
# fix SIGSEGV of the syntax check in ksh emulation mode (#1222867)
Patch12: zsh-5.0.7-ksh-syntax-check.patch
BuildRequires: coreutils sed ncurses-devel libcap-devel BuildRequires: coreutils sed ncurses-devel libcap-devel
BuildRequires: texinfo texi2html gawk hostname BuildRequires: texinfo texi2html gawk hostname
@ -74,16 +54,9 @@ This package contains the Zsh manual in html format.
%prep %prep
%setup -q %setup -q
%patch0 -p1 -b .serial %patch0 -p1
%patch4 -p1 %patch1 -p1
%patch5 -p1 %patch2 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
cp -p %SOURCE7 . cp -p %SOURCE7 .
@ -201,6 +174,9 @@ fi
%doc Doc/*.html %doc Doc/*.html
%changelog %changelog
* Wed Jun 03 2015 Kamil Dudka <kdudka@redhat.com> - 5.0.8-1
- Update to latest upstream release: Zsh 5.0.8
* Fri May 22 2015 Kamil Dudka <kdudka@redhat.com> - 5.0.7-8 * Fri May 22 2015 Kamil Dudka <kdudka@redhat.com> - 5.0.7-8
- fix SIGSEGV of the syntax check in ksh emulation mode (#1222867) - fix SIGSEGV of the syntax check in ksh emulation mode (#1222867)