According to the documentation:
To prevent the shell from sending the SIGHUP signal to a particular
job, it should be removed from the jobs table with the disown builtin
or marked to not receive SIGHUP using disown -h.
https://www.gnu.org/software/bash/manual/html_node/Signals.html
Note the OR in the quote.
I can confirm that simply using disown
without -h
and re-logging that the process did not exit:
#!/bin/bash
( sleep 10s; echo 1 > b ) &
disown
It seems that the -h
option is not necessary? If it works without then what is its purpose?
Best Answer
Without
-h
the job is removed from the table of active jobs, with-h
it is not.Everything is in the manual:
To see the difference run
jobs
after disowning the job with and without-h
.