void createProcess(bool createIndependentRootProcesses = false) { //change UniquePid UniquePid::resetOnFork(upid()); dmtcp::Util::initializeLogFile(_pInfo.procname()); JTRACE("Creating process during restart") (upid()) (_pInfo.procname()); RestoreTargetMap::iterator it; for (it = targets.begin(); it != targets.end(); it++) { RestoreTarget *t = it->second; if (_pInfo.upid() == t->_pInfo.upid()) { continue; } else if (_pInfo.isChild(t->upid()) && t->_pInfo.sid() != _pInfo.pid()) { t->createDependentProcess(true); } } if (createIndependentRootProcesses) { RestoreTargetMap::iterator it; for (it = independentProcessTreeRoots.begin(); it != independentProcessTreeRoots.end(); it++) { RestoreTarget *t = it->second; if (t != this) { t->createDependentProcess(false); } } } // If we were the session leader, become one now. if (_pInfo.sid() == _pInfo.pid()) { if (getsid(0) != _pInfo.pid()) { JWARNING(setsid() != -1) (getsid(0)) (JASSERT_ERRNO) .Text("Failed to restore this process as session leader."); } } // Now recreate processes with sid == _pid for (it = targets.begin(); it != targets.end(); it++) { RestoreTarget *t = it->second; if (_pInfo.upid() == t->_pInfo.upid()) { continue; } else if (t->_pInfo.sid() == _pInfo.pid()) { t->createDependentProcess(_pInfo.isChild(t->upid())); } } // Now close all open fds except _fd; for (it = targets.begin(); it != targets.end(); it++) { RestoreTarget *t = it->second; if (t != this) { close(t->fd()); } } // Create the ckpt-dir fd so that the restarted process can know about // the abs-path of ckpt-image. dmtcp::string deviceName = jalib::Filesystem::GetDeviceName(_fd); dmtcp::string dirName = jalib::Filesystem::DirName(deviceName); int dirfd = open(dirName.c_str(), O_RDONLY); JASSERT(dirfd != -1) (JASSERT_ERRNO); if (dirfd != PROTECTED_CKPT_DIR_FD) { JASSERT(dup2(dirfd, PROTECTED_CKPT_DIR_FD) == PROTECTED_CKPT_DIR_FD); close(dirfd); } dmtcp::CoordinatorAPI coordinatorAPI; coordinatorAPI.connectToCoordinator(); dmtcp::Util::runMtcpRestore(_path.c_str(), _fd, _extDecompPid, _pInfo.argvSize(), _pInfo.envSize()); JASSERT ( false ).Text ( "unreachable" ); }