delete the pid file
187705
def delete_pid(self, force_del=False):
        
        pid = self.read_pid()
        if pid != getpid() or force_del:
            logger.debug('process %d tried to delete pid' % getpid())
            return False

        if access(self.pid_file_name, F_OK):
            try:
                remove(self.pid_file_name)  # remove the old pid file
                logger.debug('delete pid (%d)' % getpid())
            except:
                logger.debug("can't delete pid file")
596820
def _clean_pid(self, pid):
        
        if isinstance(pid, (list, tuple)):
            if len(pid) == 1:
                return pid[0]
            else:
                return pid
        return pid
1176684
def stop(self):
    """"""

    log.info('Stopping %s' % self)

    pids = list(self._processes)

    # Clean up the context
    for pid in pids:
      self.terminate(pid)

    while self._connections:
      pid = next(iter(self._connections))
      conn = self._connections.pop(pid, None)
      if conn:
        conn.close()

    self.__loop.stop()
29143
def delete(self):
        
        fcid = None
        pid = None

        if isinstance(self, File):
            fcid = self.fid
            pid = self.cid
        elif isinstance(self, Directory):
            fcid = self.cid
            pid = self.pid
        else:
            raise APIError('Invalid BaseFile instance.')

        if not self._deleted:
            if self.api._req_rb_delete(fcid, pid):
                self._deleted = True
                return True
        else:
            raise APIError('This file or directory is already deleted.')
827617
def release(self):
        
        try:
            self.pidfile.close()
            os.remove(self._pidfile)
        except OSError as err:
            if err.errno != 2:
                raise
135493
def stop(self):
        """"""
        pid = None
        if os.path.exists(self.pidfile):
            with open(self.pidfile, 'r') as fp:
                pid = int(fp.read().strip())

        if not pid:
            msg = 'pidfile (%s) does not exist. Daemon not running?\n'
            sys.stderr.write(msg % self.pidfile)
            return

        try:
            while 1:
                os.kill(pid, SIGTERM)
                time.sleep(0.1)
        except OSError as e:
            e = str(e)
            if e.find('No such process') > 0:
                if os.path.exists(self.pidfile):
                    os.remove(self.pidfile)
                else:
                    print(e)
                    sys.exit(1)
53318
def cleanup(config_dir):
    """"""
    stdout_path = os.path.join(config_dir, 'pueue.stdout')
    stderr_path = os.path.join(config_dir, 'pueue.stderr')
    if os._exists(stdout_path):
        os.remove(stdout_path)
    if os._exists(stderr_path):
        os.remove(stderr_path)

    socketPath = os.path.join(config_dir, 'pueue.sock')
    if os.path.exists(socketPath):
        os.remove(socketPath)
422805
def delete(self):
        
        try:
            if self.pid.is_new():
                self.pid.delete()
            else:
                self.pid.delete()
                self.api.metadata_delete(self.pid.pid_value)
        except (DataCiteError, HttpError):
            logger.exception("Failed to delete in DataCite",
                             extra=dict(pid=self.pid))
            raise
        logger.info("Successfully deleted in DataCite",
                    extra=dict(pid=self.pid))
        return True
1129434
def release(self):
        """"""
        if self.lock_filename != self.pid_filename:
            try:
                os.unlink(self.lock_filename)
            except OSError:
                pass

        try:
            os.remove(self.pid_filename)
        except OSError:
            pass
551954
def daemon_stop(pidfile, sig=None):
    
    logger.debug("stop daemon application pidfile={pidfile}.".format(pidfile=pidfile))
    pid = load_pid(pidfile)
    logger.debug("load pid={pid}".format(pid=pid))
    if not pid:
        six.print_("Application is not running or crashed...", file=os.sys.stderr)
        os.sys.exit(195)
    process_kill(pid, sig)
    return pid
458455
private boolean dropPidFile() {
        LOG.trace("Entering dropPidFile()");

        // we cannot create pid files on Windows
        if (System.getProperty("os.name").startsWith("Windows")) {
            LOG.info("Pid file creation is unsupported on Windows... skipping");
            return true;
        }

        try {
            final String[] cmd = {"bash", "-o", "noclobber", "-c", "echo $PPID > " + pidFilename};
            final Process p = Runtime.getRuntime().exec(cmd);

            if (p.waitFor() != 0) {
                LOG.error("Unable to drop PID file");
                return false;
            }
        } catch (final InterruptedException | IOException e) {
            LOG.error("Unable to drop PID file: " + e.getMessage());
            return false;
        }

        // This must be called after we've successfully dropped the PID file. Otherwise, it might clean-up another
        // instances PID file. Keep in mind this doesn't account for kill -9 or a hard lockup. The start-up script
        // should provide some additional logic to clean-up stale pid files.
        new File(pidFilename).deleteOnExit();

        LOG.debug("Dropped PID file");
        LOG.trace("Exiting dropPIDFile()");
        return true;
    }
1110505
def stop(pid):
    
    if psutil.pid_exists(pid):
      try:
        p = psutil.Process(pid)
        p.kill()
      except Exception:
        pass
410589
protected function _killPid()
    {
        if (file_exists($this->_pidFile)) {
            unlink($this->_pidFile);
        }
        if ($this->_pid) {
            posix_kill($this->_pid, SIGTERM);
        }
    }
1030307
private void cleanupProcess(LinuxProcess linuxProcess, int stdinFd, int stdoutFd, int stderrFd)
   {
      pidToProcessMap.remove(linuxProcess.getPid());
      fildesToProcessMap.remove(stdinFd);
      fildesToProcessMap.remove(stdoutFd);
      fildesToProcessMap.remove(stderrFd);

      //        linuxProcess.close(linuxProcess.getStdin());
      //        linuxProcess.close(linuxProcess.getStdout());
      //        linuxProcess.close(linuxProcess.getStderr());

      if (linuxProcess.cleanlyExitedBeforeProcess.get()) {
         linuxProcess.onExit(0);
         return;
      }

      IntByReference ret = new IntByReference();
      int rc = LibC.waitpid(linuxProcess.getPid(), ret, LibC.WNOHANG);

      if (rc == 0) {
         deadPool.add(linuxProcess);
      }
      else if (rc < 0) {
         linuxProcess.onExit((Native.getLastError() == LibC.ECHILD) ? Integer.MAX_VALUE : Integer.MIN_VALUE);
      }
      else {
         handleExit(linuxProcess, ret.getValue());
      }
   }
852648
function removePIDFile(name) {
  var pidFilePath = pidDir + name + '.pid';
  fs.exists(pidFilePath, function(exists) {
    if (exists) {
      fs.unlinkSync(pidFilePath);
    }
  });
}
1309548
def remove(self):
        
        with self.__lock:
            absolute_file_path = self.__file_path
            #logging.debug("DELETE data file %s", absolute_file_path)
            if os.path.isfile(absolute_file_path):
                os.remove(absolute_file_path)
1148724
def _psutil_kill_pid(pid):
    
    try:
        parent = Process(pid)
        for child in parent.children(recursive=True):
            child.kill()
        parent.kill()
    except NoSuchProcess:
        return