Disown won't take -h option
bash
, zsh
and ksh93
are the shells that have a disown
command. Of the three, bash
is the only one that supports a h
option. Without -h
it emultates zsh
behavior (remove from the job table), while with -h
it emulates ksh93
behavior (will not send it a SIGHUP upon exit, but doesn't remove it from the job table so you can still bg
or fg
or kill it).
You could emulate that behavior with zsh, by doing:
typeset -A nohup
trap 'disown %${(k)^nohup}' EXIT
trap 'for i (${(k)nohup}) (($+jobstate[i])) || unset "nohup[$i]"' CHLD
So the nohup associative array holds the list of jobs that are not to be sent a SIGHUP upon exit. So, instead of disown -h %1
, you'd write nohup[1]=
.
See also setopt nohup
to not send SIGHUP to any job upon exit.
disown
on its own is sufficient to let the program keep running after you disconnect:
$ command_running_forever
^Z
zsh: suspended command_running_forever
$ bg
[1] + continued command_running_forever
$ jobs
[1] + running command_running_forever
$ disown %1
$ logout
disown -h
uses a bash argument which causes the job to remain on the job table and does not receive a SIGHUP when bash receives a SIGHUP (according to bash's help disown
). This argument is not available with zsh.