在不阻塞C++程序的情况下,从C++程序启动macosx.app的最佳方法是什么?
ie在路径:上获得macos x应用程序
/somewhere/foo.app
我如何在C++程序中:
int main() {
run_mac_app("/somewhere/foo.app"); // returns immediately
// after main exits, foo.app continues running.
}
如何实现run_mac_app
?
我想这就是您需要在终端中运行的:
open -a /somewhere/foo.app
如果你想让这个应用程序在后台运行,那么你必须添加-g
open -g -a /somewhere/foo.app
最后,
#include <cstdlib>
#include <fstream>
#include <iostream>
int main()
{
std::system("open -g -a /somewhere/foo.app");
}
参考来源:
https://en.cppreference.com/w/cpp/utility/program/system
https://pubs.opengroup.org/onlinepubs/009695399/functions/exec.html