mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-15 01:17:45 +00:00
c35fe879c7
This changes how fish attempts to protect itself from calling tcsetpgrp() too aggressively. Recall that tcsetpgrp() will "force" itself, if SIGTTOU is ignored (which it is in fish when job control is enabled). Prior to this fix, we avoided SIGTTINs by only transferring the tty ownership if fish was already the owner. This dated from a time before we had really nailed down how pgroups should be assigned. Now we more deliberately assign a job's pgroup so we don't need this conservative check. However we still need logic to avoid transferring the tty if fish is not the owner. The bad case is when job control is enabled while fish is running in the background - here fish would transfer the tty and "steal" from the foreground process. So retain the checks of the current tty owner but migrate them to the point of calling tcsetpgrp() itself.
21 lines
642 B
Fish
21 lines
642 B
Fish
#RUN: env fth=%fish_test_helper %fish %s
|
|
|
|
# Ensure job control works in non-interactive environments.
|
|
|
|
status job-control full
|
|
/bin/echo hello
|
|
#CHECK: hello
|
|
|
|
$fth print_pgrp | read first
|
|
$fth print_pgrp | read second
|
|
test $first -ne $second
|
|
and echo "pgroups differed, meaning job control worked"
|
|
or echo "pgroups were the same, job control did not work"
|
|
#CHECK: pgroups differed, meaning job control worked
|
|
|
|
# fish ignores SIGTTIN and so may transfer the tty even if it
|
|
# doesn't own the tty. Ensure that doesn't happen.
|
|
set -l fish (status fish-path)
|
|
$fish -c 'status job-control full ; $fth report_foreground' &
|
|
wait
|
|
#CHECKERR: background
|