about summary refs log tree commit diff
path: root/Test
diff options
context:
space:
mode:
authorPeter Stephenson <p.stephenson@samsung.com>2022-03-30 09:28:43 +0100
committerPeter Stephenson <p.stephenson@samsung.com>2022-03-30 09:28:43 +0100
commit98e46340867028808e71e7f3373881cb7e5b6764 (patch)
treece804301a1890959e620dabf3e87da5a63503f80 /Test
parentf11227f78d8d477048194df5b93dfe315d4b1588 (diff)
downloadzsh-98e46340867028808e71e7f3373881cb7e5b6764.tar.gz
zsh-98e46340867028808e71e7f3373881cb7e5b6764.tar.xz
zsh-98e46340867028808e71e7f3373881cb7e5b6764.zip
49906 (Bart), 49911: Fixes to querying jobs in subshell.
Don't attempt to query invalid job off end of table, resulting in
crashes from $jobtstates.

If background task started in subshell, look at tatsks within subshell
instead of main shell.  Document and add test.
Diffstat (limited to 'Test')
-rw-r--r--Test/W03jobparameters.ztst28
1 files changed, 28 insertions, 0 deletions
diff --git a/Test/W03jobparameters.ztst b/Test/W03jobparameters.ztst
index af889c6d5..a6f7a09b1 100644
--- a/Test/W03jobparameters.ztst
+++ b/Test/W03jobparameters.ztst
@@ -48,3 +48,31 @@
 *>running:+:*=running
 *>running:+:*=running
 *>zsh:*SIGHUPed*
+
+# $jobstates refers to a job started in the main shell unless
+# one has been started in the subshell.  In the latter case,
+# the subshell has no job control so the job is not marked as current.
+  zpty_start
+  zpty_input "MODULE_PATH=${(q)MODULE_PATH}"
+  zpty_input 'sleep 3 &'
+  zpty_input '(print main; print $jobstates; sleep 2& print sub; print $jobstates)'
+  zpty_input 'jobs -s'
+  zpty_stop
+0:$jobstate shows one job started in main shell or one started in subshell
+*>\[1] [0-9]##
+>main
+*>running:+:*=running
+>sub
+*>running::*=running
+*>zsh:*SIGHUPed*
+
+# output from zpty removes empty lines
+  zpty_start
+  zpty_input "MODULE_PATH=${(q)MODULE_PATH}"
+  zpty_input '(print main; print $jobstates; sleep 2& print sub; print $jobstates)'
+  zpty_input 'jobs -s'
+  zpty_stop
+0:$jobstate shows no job started in main shell but one started in subshell
+>main
+>sub
+*>running::*=running