我怎么能等到指定的" xterm的"完了吗? [英] How can I wait until specified "xterm" finished?
问题描述
在我的C-shell文件,我不喜欢的东西:
In my c-shell file, I did something like:
的xterm -e源xxxx0&放大器;
xterm -e "source xxxx0" &
的xterm -e源xxxx1与&
xterm -e "source xxxx1" &
等
code ....
code....
它工作正常,经过code等待将执行两个的xterm结束后。
It works fine that code after "wait" will be executed after the two xterm finished.
不过,这也给了问题。如果我有一些PS打开,就像打开geditn一个txt文件,或者我有开放的日食,它会因为等待正在等待完成所有作业挂在那里。
But it also gives problem. If I have some ps open, like an txt file opened by geditn, or I have an eclipse open, it will hung there since "wait" is waiting for all jobs to be finished.
那么,如何才能让等待等待只为这两个xterm的工作。
So how can I let "wait" only wait for those two xterm jobs.
或在另一个词,我想这两个xterm的同时运行。之后他们都做了,code可以继续。我该怎样做呢?
Or in another word, I want those two "xterm" run concurrently. And after they both done, the code can be continued. How shall I do that?
非常感谢你。
推荐答案
告诉等
进程ID应该等待:
Tell wait
the process ids it should wait for:
xterm ... &
pid1=$!
xterm ... &
pid2=$!
wait $pid1 $pid2
这是假设你使用的shell,其中等
支持多种参数(bash中,zsh中,...)。如果你使用的是sh便携性,那么你必须做两等待:
That's assuming you use a shell where wait
supports multiple arguments (bash,zsh, ...). If you use sh for portability, then you have to do two waits:
wait $pid1
wait $pid2
这将等待直到双方完成。如果说之前的第二个结束的第一个,等待将立即返回。
This will wait untill both are finished. If the second finishes before the first, the wait will immediately return.
这篇关于我怎么能等到指定的" xterm的"完了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!