Job gets stopped when typing on terminal
- Found in: 1.19
Steps to reproduce:
- In a terminal, start a program running in the background with pola-run:
pola-run -B --x11 -e xeyes &
- The program starts running in the background fine. xeyes follows the pointer.
- Type something at the keyboard.
Expected behaviour: The process carries on working.
Actual behaviour: If you press Enter, you get this:
[1]+ Stopped pola-run -B --x11 -e xeyes
If you strace pola-run, you will find that it is blocked on read(). The problem is that when you enter input via the tty, poll() tells pola-run that there is input waiting. But pola-run is not in the right progress group to read the input from the tty FD, and the read() call causes the whole process group to receive a stop signal. This stops all the processes in the process group from running until you foreground the process group from the shell.
This is one of the cases in which file descriptors do not behave like capabilities (see FileDescriptorsAsCapabilities).
Workaround
Redirect stdin to /dev/null, e.g.
pola-run -B --x11 -e xeyes </dev/null &
Questions
Can we fix this by setting the signal handler for SIGTTIN to SIG_IGN?
