递归sigstop

发布于 2025-01-30 04:47:58 字数 151 浏览 1 评论 0原文

我可以使用以下pid将停止信号发送到PID:

kill -STOP PID

然后恢复:

kill -CONT PID

如何递归将其发送给树中的所有PID的孩子?

I can send a STOP signal to a pid using:

kill -STOP PID

And then resume it:

kill -CONT PID

How do I recursively send this to all the children of the pid in the tree as well?z

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

零時差 2025-02-06 04:47:58

这是为了冻结Fluxbox及其所有的孩子。

因此,我写了一个可以解决问题的脚本。

fbpid="$(pgrep fluxbox)"
pidlist="$(ps h --ppid ${fbpid} -o pid)"
pnamelist="$(ps h --ppid ${fbpid} -o command)"

echo -e "We will be suspending these processes: \n${pnamelist}\n"
read -p "Continue?"

for pid in ${pidlist}
    do
    kill -STOP "$pid"
done
kill -STOP "$fbpid"

read -p "Resume fluxbox and children?"

for pid in ${pidlist}
    do
    kill -CONT "$pid"
done
kill -CONT "$fbpid"

自然,它必须从tmux/屏幕/TTY/控制台启动。

This was to freeze fluxbox and all it's children.

So I wrote a script that does the trick.

fbpid="$(pgrep fluxbox)"
pidlist="$(ps h --ppid ${fbpid} -o pid)"
pnamelist="$(ps h --ppid ${fbpid} -o command)"

echo -e "We will be suspending these processes: \n${pnamelist}\n"
read -p "Continue?"

for pid in ${pidlist}
    do
    kill -STOP "$pid"
done
kill -STOP "$fbpid"

read -p "Resume fluxbox and children?"

for pid in ${pidlist}
    do
    kill -CONT "$pid"
done
kill -CONT "$fbpid"

Naturally, it has to be launched from tmux/screen/tty/console.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文