Noosphere Possibilities Maximized
Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

ps-native

0.0.4 • Public • Published

ps-native

Native Node.js binding for enumerate, find and kill processes by OS specific API

Installation

Note: The module is uses the node-gyp and c++ compiler with c++11 support to build the extension.

You can use npm to download and install it:

  • The latest ps-native package: npm install ps-native
  • GitHub's master branch: npm install https://github.com/kalexey89/node-ps-native/tarball/master

Supported OS and platforms

OS:

  • Windows (desktop: Window 7+, server: Windows Server 2008+);
  • Linux (any Linux-based distributives);
  • MacOS (plans...).

Platforms:

  • Node.js (version >= 4);
  • NW.js (if NW.js contains a supported version of Node.js).

Usage

Note: the module must be installed before use.

const ps = require('ps-native');
 
/*
 * Enumerate processes
 */
 
ps.enum(['pid', 'name'], (error, proclist) => {
    if (null === error) console.log(proclist);
    else throw error;
});
 
 
/*
 * Find processes
 */
 
// By PID
ps.find(4354, ['pid', 'name'], (error, proc) => {
    if (null === error) console.log(proc);
    else throw error;
});
 
// By name
ps.find('gedit', ['pid', 'name'], (error, proclist) => {
    if (null === error) console.log(proclist);
    else throw error;
});
 
// By regexp
ps.find(/ch.*/, ['pid', 'name'], (error, proclist) => {
    if (null === error) console.log(proclist);
    else throw error;
});
 
 
/*
 * Kill process
 */
 
ps.kill(4532, ps.SIGTERM, (error) => {
    if (null !== error) throw error;
});

API

See the API documentation in the wiki.

Testing

mocha is required to run unit tests.

In ps-native directory (where its package.json resides) run the following:

npm install mocha
npm test

License

MIT, © 2017 Kuznetsov Aleksey (kalexey89).

install

npm i ps-native

Downloadsweekly downloads

1

version

0.0.4

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability