GithubHelp home page GithubHelp logo

linusu / node-tree-kill Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pkrumins/node-tree-kill

0.0 3.0 0.0 25 KB

kill trees of processes

License: MIT License

JavaScript 92.31% TypeScript 7.69%

node-tree-kill's Introduction

Tree Kill

Kill all processes in the process tree, including the root process.

Examples

Kill all the descendent processes of the process with pid 1, including the process with pid 1 itself:

var kill = require('tree-kill');
kill(1);

Send a signal other than SIGTERM.:

var kill = require('tree-kill');
kill(1, 'SIGKILL');

Run a callback when done killing the processes. Passes an error argument if there was an error.

var kill = require('tree-kill');
kill(1, 'SIGKILL', function(err) {
    // Do things
});

You can also install tree-kill globally and use it as a command:

tree-kill 1          # sends SIGTERM to process 1 and its descendents
tree-kill 1 SIGTERM  # same
tree-kill 1 SIGKILL  # sends KILL instead of TERMINATE

Methods

require('tree-kill')(pid, [signal], [callback]);

Sends signal signal to all children processes of the process with pid pid, including pid. Signal defaults to SIGTERM.

For Linux, this uses ps -o pid --no-headers --ppid PID to find the parent pids of PID.

For Darwin/OSX, this uses pgrep -P PID to find the parent pids of PID.

For Windows, this uses 'taskkill /pid PID /T /F' to kill the process tree. Note that on Windows, sending the different kinds of POSIX signals is not possible.

Install

With npm do:

npm install tree-kill

License

MIT

Changelog

[1.2.0] - 2017-19-09

Added

  • TypeScript definitions

Changed

  • kill(pid, callback) works. Before you had to use kill(pid, signal, callback)

[1.1.0] - 2016-05-13

Added

  • A tree-kill CLI

[1.0.0] - 2015-09-17

Added

  • optional callback
  • Darwin support

node-tree-kill's People

Contributors

billiegoose avatar borekb avatar jub3i avatar orodley avatar pkrumins avatar twolfson avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.