3

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?

1 Answer 1

5

Without -h the job is removed from the table of active jobs, with -h it is not.

Everything is in the manual:

 disown [-ar] [-h] [jobspec ...]

       (...)
       If the -h option is given, each jobspec is not removed
       from the table, but is marked so that SIGHUP is not sent to the
       job  if  the shell  receives  a SIGHUP.

To see the difference run jobs after disowning the job with and without -h.

1
  • I was reading the gnu.org manual which I've added a link to below the quote in my post. This is MUCH clearer.
    – Zhro
    Jul 1, 2016 at 16:54

You must log in to answer this question.

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