庆典:默默终止后台功能的过程 [英] bash: silently kill background function process
本文介绍了庆典:默默终止后台功能的过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
外壳大师,
我有一个bash shell脚本,在我启动一个后台功能,比如说富(),以显示一个无聊的和长期的命令一个进度条:
富()
{
而[1]
做
#massively酷进度条显示code
睡眠1
DONE
}富&安培;
foo_pid = $!boring_and_long_command
杀$ foo_pid>的/ dev / null的2 - ;&放大器; 1
睡眠10
现在,当富死了,我看到下面的文字:
/家庭/用户/脚本:行XXX:30290杀富
这完全破坏了我的迷死人,否则大量凉,进度条显示。我该如何摆脱这个消息的?
蒂亚,
prmatta P>
解决方案
杀$ foo_pid
等待$ foo_pid 2 - ;的/ dev / null的
顺便说一句,我不知道您的大规模酷进度条,但你见过管浏览器(PV)? http://www.ivarch.com/programs/pv.shtml
shell gurus,
I have a bash shell script, in which I launch a background function, say foo(), to display a progress bar for a boring and long command:
foo()
{
while [ 1 ]
do
#massively cool progress bar display code
sleep 1
done
}
foo &
foo_pid=$!
boring_and_long_command
kill $foo_pid >/dev/null 2>&1
sleep 10
now, when foo dies, I see the following text:
/home/user/script: line XXX: 30290 Killed foo
This totally destroys the awesomeness of my, otherwise massively cool, progress bar display. How do I get rid of this message?
tia, prmatta
解决方案
kill $foo_pid
wait $foo_pid 2>/dev/null
BTW, I don't know about your massively cool progress bar, but have you seen Pipe Viewer (pv)? http://www.ivarch.com/programs/pv.shtml
这篇关于庆典:默默终止后台功能的过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文