关于 disown 内置选项 -h 的 Bash 文档说明

Zhr*_*hro 3 bash signals job-control disown

根据文档:

为防止 shell 向特定作业发送 SIGHUP 信号,应使用 disown 内置命令将其从作业表中删除, 使用 disown -h 标记为不接收 SIGHUP。

https://www.gnu.org/software/bash/manual/html_node/Signals.html

注意引用中的OR

我可以确认只需使用disownwithout-h并重新登录该进程没有退出:

#!/bin/bash

( sleep 10s; echo 1 > b ) &
disown
Run Code Online (Sandbox Code Playgroud)

这个-h选项好像没有必要吧?如果它没有工作,那么它的目的是什么?

jim*_*mij 5

如果没有-h将作业从活动作业表中删除,-h则不会。

一切都在手册中:

 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.
Run Code Online (Sandbox Code Playgroud)

要查看在jobs使用和不使用-h.