Exemplo n.º 1
0
extern "C" int fclose(FILE *fp)
{
  int fd = fileno(fp);
  if (dmtcp::ProtectedFDs::isProtected(fd))
  {
    JTRACE("blocked attempt to fclose protected fd") (fd);
    errno = EBADF;
    return -1;
  }

#ifdef EXTERNAL_SOCKET_HANDLING
  dmtcp::ConnectionIdentifier conId;

  if (dmtcp::WorkerState::currentState() == dmtcp::WorkerState::RUNNING &&
       dmtcp::DmtcpWorker::waitingForExternalSocketsToClose() == true &&
       dup2(fd,fd) != -1) {
    conId = dmtcp::KernelDeviceToConnection::instance().retrieve(fd).id();
  }

  int rv = _real_fclose(fp);

  if (rv == 0) {
    processClose(conId);
  }
#else
  int rv = _real_fclose(fp);
#endif

  return rv;
}
Exemplo n.º 2
0
extern "C" int fclose(FILE *fp)
{
  int fd = fileno(fp);
  if (dmtcp::ProtectedFDs::isProtected(fd)) {
    JTRACE("blocked attempt to fclose protected fd") (fd);
    errno = EBADF;
    return -1;
  }
  return _real_fclose(fp);
}
Exemplo n.º 3
0
extern "C" int fclose(FILE *fp)
{
  // If this fp was obtained using popen(), we must pclose it
  if (dmtcp_is_popen_fp(fp)) {
    return pclose(fp);
  }
  int fd = fileno(fp);
  if (DMTCP_IS_PROTECTED_FD(fd)) {
    JTRACE("blocked attempt to fclose protected fd") (fd);
    errno = EBADF;
    return -1;
  }
  return _real_fclose(fp);
}
Exemplo n.º 4
0
extern "C" int fclose(FILE *fp)
{
  int fd = fileno(fp);
  if (dmtcp_is_protected_fd(fd)) {
    JTRACE("blocked attempt to fclose protected fd") (fd);
    errno = EBADF;
    return -1;
  }

  DMTCP_DISABLE_CKPT();
  int rv = _real_fclose(fp);
  if (rv == 0 && dmtcp_is_running_state()) {
    process_fd_event(SYS_close, fd);
  }
  DMTCP_ENABLE_CKPT();

  return rv;
}