/* * Setup a virtual coordinator. It's part of the running process (i.e., no * separate process is created). * * FIXME: This is the only place in this file where we use JSocket. May be get * rid of it here too? */ void setupVirtualCoordinator(CoordinatorInfo *coordInfo, struct in_addr *localIP) { string host = ""; int port; getCoordHostAndPort(COORD_NONE, host, &port); jalib::JSocket sock = jalib::JServerSocket(jalib::JSockAddr::ANY, port).sockfd(); JASSERT(sock.isValid()) (port) (JASSERT_ERRNO) .Text("Failed to create listen socket."); Util::changeFd(sock.sockfd(), PROTECTED_COORD_FD); JASSERT(Util::isValidFd(coordinatorSocket)); setCoordPort(sock.port()); pid_t ppid = getppid(); Util::setVirtualPidEnvVar(INITIAL_VIRTUAL_PID, ppid, ppid); UniquePid coordId = UniquePid(INITIAL_VIRTUAL_PID, UniquePid::ThisProcess().hostid(), UniquePid::ThisProcess().time()); coordInfo->id = coordId.upid(); coordInfo->timeStamp = coordId.time(); coordInfo->addrLen = 0; if (getenv(ENV_VAR_CKPT_INTR) != NULL) { coordInfo->interval = (uint32_t)strtol(getenv(ENV_VAR_CKPT_INTR), NULL, 0); } else { coordInfo->interval = 0; } memset(&coordInfo->addr, 0, sizeof(coordInfo->addr)); memset(localIP, 0, sizeof(*localIP)); }
dmtcp::ProcessInfo::ProcessInfo() { char buf[PATH_MAX]; _do_lock_tbl(); _pid = -1; _ppid = -1; _gid = -1; _sid = -1; _isRootOfProcessTree = false; _noCoordinator = false; _childTable.clear(); _pthreadJoinId.clear(); _procSelfExe = jalib::Filesystem::ResolveSymlink("/proc/self/exe"); _uppid = UniquePid(); JASSERT(getcwd(buf, sizeof buf) != NULL); _launchCWD = buf; #ifdef CONFIG_M32 _elfType = Elf_32; #else _elfType = Elf_64; #endif _restoreBufLen = RESTORE_TOTAL_SIZE; _restoreBufAddr = 0; _do_unlock_tbl(); }
void dmtcp::ProcessInfo::refresh() { _pid = getpid(); _ppid = getppid(); _gid = getpgid(0); _sid = getsid(0); _fgid = -1; // Try to open the controlling terminal int tfd = _real_open("/dev/tty", O_RDWR); if (tfd != -1) { _fgid = tcgetpgrp(tfd); _real_close(tfd); } if (_ppid == 1) { _isRootOfProcessTree = true; _uppid = UniquePid(); } else { _uppid = UniquePid::ParentProcess(); } _procname = jalib::Filesystem::GetProgramName(); _hostname = jalib::Filesystem::GetCurrentHostname(); _upid = UniquePid::ThisProcess(); _noCoordinator = dmtcp_no_coordinator(); char buf[PATH_MAX]; JASSERT(getcwd(buf, sizeof buf) != NULL); _ckptCWD = buf; _sessionIds.clear(); refreshChildTable(); JTRACE("CHECK GROUP PID")(_gid)(_fgid)(_ppid)(_pid); }