mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-01 21:21:15 -03:00
Fix crash on "bg" of non-job-controlled job
fish -c 'sleep 1 & bg %1' is supposed to fail because the job is not
under job control.
When we try to print the failure, we accidentally still
hold a borrow of the job list. This blows up because we use
"builtin_print_help_error()" to print the failure message; that
function runs "job_reap()" which wants an exclusive borrow of the
job list. Let's drop our job list earlier.
(cherry picked from commit 26116b477e)
This commit is contained in:
@@ -17,12 +17,13 @@ fn send_to_bg(
|
||||
let err = {
|
||||
let job = &jobs[job_pos];
|
||||
wgettext_fmt!(
|
||||
"%ls: Can't put job %s, '%ls' to background because it is not under job control\n",
|
||||
cmd,
|
||||
job.job_id().to_wstring(),
|
||||
job.command()
|
||||
)
|
||||
"%ls: Can't put job %s, '%ls' to background because it is not under job control\n",
|
||||
cmd,
|
||||
job.job_id().to_wstring(),
|
||||
job.command()
|
||||
)
|
||||
};
|
||||
drop(jobs);
|
||||
builtin_print_help_error(parser, streams, cmd, &err);
|
||||
return STATUS_CMD_ERROR;
|
||||
}
|
||||
|
||||
@@ -18,3 +18,6 @@ or echo "pgroups were the same, job control did not work"
|
||||
$fish -c 'status job-control full ; $fth report_foreground' &
|
||||
wait
|
||||
#CHECKERR: background
|
||||
|
||||
$fish -c 'sleep .2 & bg %1'
|
||||
#CHECKERR: bg: Can't put job 1, 'sleep .2 &' to background because it is not under job control
|
||||
|
||||
Reference in New Issue
Block a user