getpid

1.0.0 • Public • Published

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);
  }
}

Readme

Keywords

Package Sidebar

Install

npm i getpid

Weekly Downloads

23

Version

1.0.0

License

MIT

Unpacked Size

2.94 kB

Total Files

3

Last publish

Collaborators

  • jonhall