Does linux kill background processes if we close the terminal from which it has started?

后端 未结 4 744
傲寒
傲寒 2021-01-30 17:59

I have an embedded system, on which I do telnet and then I run an application in background:

./app_name &

Now if I close my te

4条回答
  •  伪装坚强ぢ
    2021-01-30 18:21

    When you close the terminal, shell sends SIGHUP to all background processes – and that kills them. This can be suppressed in several ways, most notably:

    nohup

    When you run program with nohup it catches SIGHUP and redirect program output.

    $ nohup app &
    

    disown

    disown tells shell not to send SIGHUP

    $ app &
    $ disown
    

    Is it dependent on version of linux?

    It is dependent on your shell. Above applies at least for bash.

提交回复
热议问题