Skip to content

xsellier/node-ps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ps-man Build Status

To install:

npm install --save ps-man

Usage

  • list
    • name : Process name - optional
    • pid : Process identifier - optional
    • clean : boolean to return clean list for mac - optional
  • kill
    • pidList : Array of process identifier - mandatory
    • signal : The default signal for kill is TERM. (see man ps) - optional - OSX/Linux only

List processes

Filter by name

var ps = require('ps-man');

// Filter by name
var options = {
  name: 'node'
};

ps.list(options, function(err, result) {
  // my stuff here
});

Filter by pid

var ps = require('ps-man');

// Filter by pid
var options = {
  pid: 1501
};

ps.list(options, function(err, result) {
  // my stuff here
});

Return a cleaned list for OSX/Linux

var ps = require('ps-man');

// Filter by pid
var options = {
  clean: true
};

ps.list(options, function(err, result) {
  // my stuff here
});

Kill processes

var ps = require('ps-man');

var options = {
  pidList: ['1501'],
  signal: '-9'
};

ps.kill(options, function(err) {
  // stuff here
});

// or could be used as following
ps.kill(['1501'], function(err) {
  // stuff here
});

License

MIT. Please see License file for more details.