gpt4 book ai didi

c++ - 在 Linux 上从 C++ 调用可执行文件,并等待它完成

转载 作者:IT王子 更新时间:2023-10-29 00:50:16 76 4
gpt4 key购买 nike

我正在尝试编写一个程序,该程序在某个时候需要通过系统调用外部应用程序并等待其他可执行文件完成。我非常想要 python subprocess.call(...) 方法的 C++ 版本。我知道 system() 可以通过 shell 调用命令,但我不知道它是否能够阻塞直到命令终止。任何人都知道这样做的正确方法吗?

我正在为 Linux 系统编写此代码,但如果可能的话,我希望它是可移植的。无论如何,我们将不胜感激。

最佳答案

system() 等待命令完成:

http://linux.die.net/man/3/system

system() executes a command specified in command by calling /bin/sh -c command, and returns after the command has been completed. During execution of the command, SIGCHLD will be blocked, and SIGINT and SIGQUIT will be ignored.

关于c++ - 在 Linux 上从 C++ 调用可执行文件,并等待它完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9101809/

76 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com