我有一个简单的bash脚本中的所有进程运行给定数量的过程:退出,壳牌开始
#!/bin/bash
# usage: ./run-abt.sh <agent count> <responder port> <publisher port>
echo "./abt-monitor 127.0.0.1 $2 $3 $1"
exec ./abt-monitor 127.0.0.1 $2 $3 $1 &
for ((i=1; i<=$1; i++))
do
echo "Running agent $i";
exec ./abt-agent 127.0.0.1 $2 $3 $i $1 > $i.txt &
done
我需要添加用户按Ctrl+C
和控制返回到bash中,所有的进程创建的时候是通过run-abt.sh
来杀死。
注意这不会启动任何代理:执行脚本的bash进程将由abt-monitor进程*替换,因为执行命令。 [文档](http://www.gnu.org/software/bash/manual/bashref.html#index-exec) –
该exec发生在由'&'运算符启动的子shell中。 – chepner