When I do

( sleep 1; read x ; echo x=$x; echo done ) & 

then with the default terminal settings, the job gets stopped by SIGTTIN.

If I do

( ( sleep 1; read x ; echo x=$x; echo done ) & )

the read syscall inside read gets EOF (returns with 0)` and no stopping by SITTIN happens.

What is the explanation for these behavior

1 Answer 1


That's because in the second case the backgrounded command will be run in a subshell, and as there's no job control in subshells, the background mode will be faked by redirecting the input from /dev/null and ignoring the SIGINT and SIGQUIT signals.

See also these answers:

Background process of subshell strange behaviour

Process started by script does not receive SIGINT

Does ` (sleep 123 &)` remove the process group from bash's job control?

Process killed before being launched in background

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.