gpt4 book ai didi

shell - 如何使用脚本暂停后台 shell?

转载 作者:行者123 更新时间:2023-12-04 23:36:15 26 4
gpt4 key购买 nike

不幸的是,我没有suspend 命令(busybox/ash)。但是我可以使用 kill -STOP $$ 从后台 shell (sh &) 返回到父 shell(以及 fg 之后)。
但是我不想输入这个长的 kill-command 我想写一个脚本(命名为 suspend)应该这样做:

#!/busybox sh
kill --STOP $$

但这没有用。看来我又开了一个shell,同时挂了。

那么什么是正确的挂起脚本,我该如何调用它(exec?)?

最佳答案

总结一下我在上面的评论中写的内容:

根据this website,为您尝试执行的操作获取简单命令的最简单方法是在您的~/.profile 中创建别名。 .

echo 'alias suspend=kill --STOP $$' >> ./~profile # Add alias to .profile
source ./~profile # Let ash update its list of aliases

现在您可以使用一个简短的suspend命令。

使用脚本可能很难做到这一点,因为子进程不能轻易(或根本)修改父进程的环境。

关于shell - 如何使用脚本暂停后台 shell?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35845423/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com