Returns the PID of the current process. The PID will also be saved in system property <code>"pid"</code>

@return PID of current progress

@throws IOException If an I/O error occurs
177114
public static String getPID() throws IOException{
        String pid = System.getProperty("pid"); //NOI18N
        if(pid==null){
            String command;
            if(OS.get().isUnix())
                command = "echo $$ $PPID";
            else{
                // getpids.exe is taken from http://www.scheibli.com/projects/getpids/index.html (GPL)
                File tempFile = File.createTempFile("getpids", "exe"); //NOI18N

                // extract the embedded getpids.exe file from the jar and save it to above file
                IOUtil.pump(RuntimeUtil.class.getResourceAsStream("getpids.exe"), new FileOutputStream(tempFile), true, true); //NOI18N
                command = tempFile.getAbsolutePath();
                tempFile.deleteOnExit();
            }
            StringTokenizer stok = new StringTokenizer(runCommand(command));
            stok.nextToken(); // this is pid of the process we spanned
            pid = stok.nextToken();
            System.setProperty("pid", pid); //NOI18N
        }
        return pid;
    }
912858
@Override public float getProgress() {
		if (length == 0)
			return 1;

		if (!isBGZF)
			return (float)(in.getPosition() - fileStart) / length;

		try {
			if (in.peek() == -1)
				return 1;
		} catch (IOException e) {
			return 1;
		}

		// Add 1 to the denominator to make sure that we never report 1 here.
		return (float)((bci.getFilePointer() >>> 16) - fileStart) / (length + 1);
	}
695789
private int openDoor(int pid) throws IOException {
        String path = tmpdir + "/.java_pid" + pid;;
        fd = open(path);

        // Check that the file owner/permission to avoid attaching to
        // bogus process
        try {
            checkPermissions(path);
        } catch (IOException ioe) {
            close(fd);
            throw ioe;
        }
        return fd;
    }
1149110
def pid(self):
        
        # We can't possibly be running if our base_pathname isn't defined.
        if not self.base_pathname:
            return None
        try:
            pidfile = os.path.join(self.base_pathname, 'postmaster.pid')
            return int(open(pidfile).readline())
        except (IOError, OSError):
            return None
1182145
private int getPid() {

	PageContext pc = ThreadLocalPageContext.get();
	if (pc == null) {
	    pc = CFMLEngineFactory.getInstance().getThreadPageContext();
	    if (pc == null) throw new RuntimeException("cannot get pid for current thread");
	}
	return pc.getId();
    }
181116
def get_pid_from_tid(self, dwThreadId):
        
        try:

            # No good, because in XP and below it tries to get the PID
            # through the toolhelp API, and that's slow. We don't want
            # to scan for threads over and over for each call.
##            dwProcessId = Thread(dwThreadId).get_pid()

            # This API only exists in Windows 2003, Vista and above.
            try:
                hThread = win32.OpenThread(
                    win32.THREAD_QUERY_LIMITED_INFORMATION, False, dwThreadId)
            except WindowsError:
                e = sys.exc_info()[1]
                if e.winerror != win32.ERROR_ACCESS_DENIED:
                    raise
                hThread = win32.OpenThread(
                    win32.THREAD_QUERY_INFORMATION, False, dwThreadId)
            try:
                return win32.GetProcessIdOfThread(hThread)
            finally:
                hThread.close()

        # If all else fails, go through all processes in the snapshot
        # looking for the one that owns the thread we're looking for.
        # If the snapshot was empty the iteration should trigger an
        # automatic scan. Otherwise, it'll look for the thread in what
        # could possibly be an outdated snapshot.
        except Exception:
            for aProcess in self.iter_processes():
                if aProcess.has_thread(dwThreadId):
                    return aProcess.get_pid()

        # The thread wasn't found, so let's refresh the snapshot and retry.
        # Normally this shouldn't happen since this function is only useful
        # for the debugger, so the thread should already exist in the snapshot.
        self.scan_processes_and_threads()
        for aProcess in self.iter_processes():
            if aProcess.has_thread(dwThreadId):
                return aProcess.get_pid()

        # No luck! It appears to be the thread doesn't exist after all.
        msg = "Unknown thread ID %d" % dwThreadId
        raise KeyError(msg)
631352
private synchronized ProgressMonitor getWorkerProgressMonitor() {
    ProgressMonitor monitor;
    if (numProgressMonitors < maxConcurrentWorkers) {
      String title = String.format("Worker (%d)", numProgressMonitors++);
      monitor = new PermanentProgressMonitor(monitorFactory.createProgressMonitor(title));
    } else {
      monitor = workerMonitorQueue.remove();
    }
    return monitor;
  }
594567
public float getProgress() throws IOException {
    if (end == start) {
      return 0.0f;
    } else {
      return Math.min(1.0f, (in.getPosition() - start) / (float)(end - start));
    }
  }
600596
public Process execute()
    throws IOException
    {
        List<String>  list = createCommandList();
        if (_LOG_.isDebugEnabled()) {
            _LOG_.debug( "executing command: " + list );
        }

        Process  proc = Runtime.getRuntime().exec( list.toArray( new String[0] ) );
                                             //@throws IOException
                                             //@throws SecurityException
                                             //@throws IndexOutOfBoundsException, NullPointerException

        return proc;
    }
81153
public function getPid()
    {
        $options = static::getOptions();
        $debug = @$options['debug'] === true;

        $pidFile = $options['pid_file'];
        if (!$pidFile)
            throw new \Exception("No pid_file in the config");

        $fpPid = fopen($pidFile, "c");
        if (!$fpPid)
            throw new \Exception("Could not open " . $pidFile);

        if (!flock($fpPid, LOCK_EX | LOCK_NB)) {
            fclose($fpPid);
            return (int)file_get_contents($pidFile);
        }

        flock($fpPid, LOCK_UN);
        fclose($fpPid);
        @unlink($pidFile);
        return false;
    }
489651
public synchronized float get() {
    Progress node = this;
    while (node.parent != null) {                 // find the root
      node = parent;
    }
    return node.getInternal();
  }
80960
public float getProgress() throws IOException {
    if (start == end) {
      return 0.0f;
    } else {
      return Math.min(1.0f, (pos - start) / (float) (end - start));
    }
  }
706743
private static Long getPid(File pidFile) {
      FileReader reader = null;
      BufferedReader lineReader = null;
      String pidLine  = null;
      try {
        reader = new FileReader(pidFile);
        lineReader = new BufferedReader(reader);
        pidLine = lineReader.readLine();
        if(pidLine!=null) {
          pidLine = pidLine.trim();     
        }   
      } catch (Exception ex) {
        log.error("Failed to read PID from file  [" + pidFile.getAbsolutePath() + "]", ex);
      } finally {
        if(reader!=null) try { reader.close(); } catch (Exception ex) { /* No Op */ }
      }
      try {
        return Long.parseLong(pidLine);
      } catch (Exception ex) {
        return null;
      }     
    }
1088415
public static String getPid() {
        if (pid == null) {
            String runtimeName = ManagementFactory.getRuntimeMXBean().getName();
            if (runtimeName == null) {
                pid = "unknown";
            } else {
                int index = runtimeName.indexOf('@');
                if (index < 0) {
                    pid = runtimeName;
                } else {
                    pid = runtimeName.substring(0, index);
                }
            }
        }
        return pid;
    }
128303
public FileStatus next() throws IOException {
    if (finished) {
      LOG.warn("Should not call next() after FINISH_TOKEN is obtained.");
      return FINISH_TOKEN;
    }
    FileStatus f = null;
    try {
      f = output.take();
    } catch (InterruptedException e) {
      finished = true;
      interruptProcessors();
      throw new IOException(e);
    }
    if (f == FINISH_TOKEN) {
      LOG.info("traversal is done. Returning FINISH_TOKEN");
      finished = true;
    }
    return f;
  }
1304713
public static final String getThreadId() {
        String id = threadids.get();
        if (null == id) {
            // Pad the tid out to 8 characters
            id = getThreadId(Thread.currentThread());
            threadids.set(id);
        }
        return id;
    }
472309
def pid(self):
        
        try:

            with open(self.pidfile, 'r') as pidfile:

                try:

                    pid = int(pidfile.read().strip())

                except ValueError:

                    return None

                try:

                    os.kill(pid, 0)

                except OSError as e:

                    if e.errno == errno.EPERM:

                        return pid

                    elif e.errno == errno.ESRCH:

                        return None

                    LOG.exception(
                        "os.kill returned unhandled error "
                        "{0}".format(e.strerror)
                    )
                    sys.exit(exit.PIDFILE_ERROR)

                return pid

        except IOError:

            if not os.path.isfile(self.pidfile):

                return None

            LOG.exception("Failed to read pidfile {0}.".format(self.pidfile))
            sys.exit(exit.PIDFILE_INACCESSIBLE)