int createProcess()
{
int retCode = ACE::daemonize();
std::cout << "retCode = " << retCode << ", lasterror = " << ACE_OS::last_error() << std::endl;
std::string command = "ping -t 10.71.211.153";
ACE_Process_Options startOption;
ACE_Process startProcess;
startOption.command_line("%s", command.c_str());
startOption.handle_inheritence(FALSE);
// 设置一下libpath
/*
const int ENVNUM = 1; //需要设置的环境变量数为2
ACE_TCHAR *pEnvString[ENVNUM+1] = {0}; //最后一个指向0
std::string libPath = "";
#ifdef WIN32
libPath = ::getenv("PATH");
#else
libPath = ACE_OS::getenv("LD_LIBRARY_PATH");
#endif
procOption.setenv();
*/
#ifdef WIN32
ACE_HANDLE fd = ACE_OS::open("nul", O_RDWR);
#else
int fd = ACE_OS::open("/dev/null", O_RDWR);
#endif
//startOption.set_handles(fd, fd, fd);
pid_t pid = startProcess.spawn(startOption);
ACE_OS::close(fd);
startProcess.wait();
return 0;
}
使用ACE_Process创建子进程
最新推荐文章于 2024-06-09 20:19:41 发布