Пример #1
0
/* Initializes log pathnames. One log per process. */
void initializeLogNames()
{
    pid_t pid = getpid();
    dmtcp::string tmpdir = dmtcp_get_tmpdir();
    snprintf(RECORD_LOG_PATH, RECORD_LOG_PATH_MAX,
             "%s/synchronization-log-%d", tmpdir.c_str(), pid);
    snprintf(RECORD_READ_DATA_LOG_PATH, RECORD_LOG_PATH_MAX,
             "%s/synchronization-read-log-%d", tmpdir.c_str(), pid);
}
void dmtcp::VirtualPidTable::writeVirtualTidToFileForPtrace(pid_t pid)
{
  pid_t tracerPid = dmtcp::Util::getTracerPid();
  if (tracerPid != 0) {
    dmtcp::ostringstream o;
    char buf[80];
    o << dmtcp_get_tmpdir() << "/virtualPidOfNewlyCreatedThread_"
      << dmtcp_get_computation_id_str() << "_" << tracerPid;

    sprintf(buf, "%d", pid);
    int fd = open(o.str().c_str(), O_CREAT|O_WRONLY|O_TRUNC, 0600);
    JASSERT(fd >= 0) (o.str()) (JASSERT_ERRNO);
    dmtcp::Util::writeAll(fd, buf, strlen(buf) + 1);
    JTRACE("Writing virtual Pid/Tid to file") (pid) (o.str());
    close(fd);
  }
}