From 98e46340867028808e71e7f3373881cb7e5b6764 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 30 Mar 2022 09:28:43 +0100 Subject: 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. --- Test/W03jobparameters.ztst | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'Test') 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 -- cgit 1.4.1