1

Why when I do command & exit in terminal (like vimiv & exit) vimiv keeps running when the terminal is closed? I expected vimiv to start as a background job in the current terminal and then receive a sighup when the terminal is closed and also exits. For example, if I execute vimiv & followed by another exit command, vimiv will close

0

1 Answer 1

0

I expected vimiv to start as a background job in the current terminal and then receive a sighup when the terminal is closed and also exits.

No, that's not what happens. vimiv would only get a SIGHUP signal (from the kernel) if it was a foreground job, or if it was a stopped background job. But it's neither: it's a running background job.

Or if bash (bash in particular, not any shell in general) had itself received a SIGHUP signal and has resent it to all its non-disowned jobs. But in your example the shells exits normally via exit, not because it was signaled by SIGHUP [1].

For example, if I execute vimiv & followed by another exit command, vimiv will close

That may be something special to that vimiv & program -- if I enter xclock & and then exit on a separate line in a terminal, xclock will not terminate. It will however terminate if I close the terminal from the X button, because in that case bash will receive a SIGHUP signal and will resend it to xclock.

[1] bash can also send a SIGHUP when exiting normally, but only with shopt -s huponexit, which is not the default.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .