fish-shell/tests/pexpects/tty_ownership.py
ridiculousfish 5cf0778207 Claim the tty unconditionally in reader_data_t::readline
When fish runs with job control enabled, it transfers ownership of the
tty to a child process, and then reclaims the tty after the process
exits. If job control is disabled then fish does not transfer or reclaim
the tty.

It may happen that the child process creates a pgroup and then transfers
the tty to it. In that case fish will not attempt to reclaim the tty, as
fish did not transfer it. Then when fish reads from stdin it will
receive SIGTTIN instead of data.

Fix this by unconditionally claiming the tty in readline().

Fixes #9181
2022-09-09 13:43:29 -07:00

29 lines
691 B
Python

#!/usr/bin/env python3
from pexpect_helper import SpawnedProc
sp = SpawnedProc()
sendline, expect_prompt = sp.sendline, sp.expect_prompt
expect_prompt()
sendline("status job-control full")
expect_prompt()
sendline(
"$fish -c 'status job-control full ; $fish_test_helper report_foreground' &; wait"
)
expect_prompt()
sendline("echo it worked")
expect_prompt("it worked")
# Regression test for #9181
sendline("status job-control interactive")
expect_prompt()
sendline("$fish_test_helper abandon_tty")
expect_prompt()
sendline("echo cool")
expect_prompt("cool")
sendline("true ($fish_test_helper abandon_tty)")
expect_prompt()
sendline("echo even cooler")
expect_prompt("even cooler")