1.0.0 • Published 2 years ago

getpid v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
2 years ago

getpid

Cross-platform PID retrieval (by process name), using ps on OSX/Unix and ms-wmic on Windows.

npm i getpid --save

Usage

const getpid = require('getpid');

async function main() {
  try {
    // get all pids for "node" processes
    const pids = await getpid('node');
  } catch (err) {
    handle_error(err);
    return;
  }

  if (!pids.length) {
    return process_not_found();
  }

  for (const pid of pids) {
    await do_something_with_pid(pid);
  }
}