如何使用脚本暂停背景shell?

时间:2016-03-07 13:46:41

标签: shell background-process suspend ash

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

#!/busybox sh
kill --STOP $$

但是这没用。我似乎打开另一个shell并同时暂停它。

那么什么是正确的暂停脚本以及如何调用它(exec?)?

1 个答案:

答案 0 :(得分:1)

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

根据this website,最简单的方法是根据~/.profileecho 'alias suspend=kill --STOP $$' >> ./~profile # Add alias to .profile source ./~profile # Let ash update its list of aliases 中创建一个别名。

suspend

现在您可以使用简短的In [265]: s.pct_change(3) Out[265]: val date 1999-03-01 NaN 1999-03-02 NaN 1999-03-03 NaN 1999-03-04 -0.017359 1999-03-05 -0.002387 1999-03-08 -0.001688 1999-03-09 0.007628 命令。

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