Why does ssh wait for my subshells without -t, and kill them with -t?

后端 未结 3 615
我在风中等你
我在风中等你 2021-02-04 05:12

I have a bash script start.sh which looks like this:

for thing in foo bar; do
    {
        background_processor $thing
        cleanup_on_exit $thing
    } &         


        
3条回答
  •  梦谈多话
    2021-02-04 05:44

    I suspect (but I’m postulating) that when there is no tty, bash is passing the SIGHUP to your forked process, which is handling the signal itself, and quietly ignoring it and continuing to tie up the SSH session.

    However, with a tty between you and the process, the tty driver is intercepting the SIGHUP, realises that it has lost the user, and forks itself to run without the ssh session as the parent.

提交回复
热议问题