首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

施用ACE_Process创建子进程

2012-11-04 
使用ACE_Process创建子进程int createProcess(){int retCode ACE::daemonize()std::cout retCode

使用ACE_Process创建子进程

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;}

热点排行