问题描述
我已经阅读了很多关于线程和睡眠和屈服的信息,但是我仍然不知道如何等待系统调用完成后再继续。
I've read a lot about threading and sleeping and yielding, but I'm still not sure how to wait until a system call is complete before continuing.
基本上,在我的程序的一个点,我调用 system(./ some-other-program)
。这工作,但是如何等待继续我的程序,直到 ./ some-other-program
已关闭?
Basically, at one point in my program, I call system("./some-other-program")
. This works, but how can I wait to continue with my program until ./some-other-program
has closed?
我在Linux上。非常感谢跨平台的解决方案,但现在只能使用Linux的解决方案。
I'm on Linux. A cross-platform solution would be greatly-appreciated, but a Linux-only one will work for now.
推荐答案
您必须执行函数将阻塞,直到程序完成。
There is nothing you have to do, the system
function will block until the program is done.
这篇关于在C ++中,我如何才能睡着,直到一个单独的程序退出才能继续?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!