0

Bash manual says

If the huponexit shell option has been set with shopt (see Section 4.3.2 [The Shopt Builtin], page 62), Bash sends a SIGHUP to all jobs when an interactive login shell exits.

Why does huponexit not work in the following?

In one interactive shell

$ shopt -s huponexit
$ sleep 4321 &
[1] 13816
$ exit

Then in the other shell

$ ps -j 13816
  PID  PGID   SID TTY      STAT   TIME COMMAND
13816 13816 13728 ?        S      0:00 sleep 4321

Thanks.

2

when an interactive login shell exits

is significant.

$ bash -l
$ shopt -s huponexit
$ sleep 120 &
[1] 24235

Then CtrlD exits (with logout, instead of exit as in your example), and

$ ps -j 24235
  PID  PGID   SID TTY      STAT   TIME COMMAND

The sleep was killed too.

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.