tmux中NOHUP和AMPERS(&)的不同行为

发布于 2025-02-12 22:27:25 字数 890 浏览 0 评论 0 原文

我了解 nohup & 的区别- 和ampersand“> nohup和ampersand之间有什么

区别

当这些启动方法以完全不会发送叹气方式配置时,这些启动方法没有区别。 https://stackoverflow.com/a/58691817

如果您使用bash,则可以使用命令shopt | Grep Hupon找出您的外壳是否向其子进程叹了口气。如果关闭,过程将不会终止, https://stackoverflow.com/a/15595391

我知道,如果 shopt | Grep Hupon 关闭,然后 nohup ./foo.sh& and ./ foo.sh& 在关闭Bash会话后仍将运行。

确实,当我通过 ps -ef |检查状态时,两者都在运行。 grep foo.sh

但是,当我参加TMUX会话时,行为是不同的。首先, shopt | Grep Hupon 在TMUX会话中也关闭。但是结果是只有 nohup ./foo.sh& 在杀死TMUX会话后可以继续运行。

TMUX会话和BASH会话之间应该有一些不同的事物,这会导致上述不同的行为。谁能解释或给出一些提示?

I learn the difference between nohup and & from What's the difference between nohup and ampersand

Based on the following answers,

There is no difference between these launching methods when the shell is configured in a way where it does not send SIGHUP at all.
https://stackoverflow.com/a/58691817

In case you're using bash, you can use the command shopt | grep hupon to find out whether your shell sends SIGHUP to its child processes or not. If it is off, processes won't be terminated,
https://stackoverflow.com/a/15595391

I learn that if shopt | grep hupon is off, then nohup ./foo.sh & and ./foo.sh & would be still running after closing the bash sessions.

Indeed, both are running when I check the status via ps -ef | grep foo.sh.

However, the behaviors are different when I move to tmux sessions. Firstly, shopt | grep hupon is also off in tmux sessions. But the result is that only nohup ./foo.sh & can keep running after killing the tmux session.

There should be something different between the tmux session and the bash session, which causes the above different behaviors. Could anyone explain it or give some hints?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文