Add node_modules

This commit is contained in:
Anton Medvedev 2023-01-10 16:49:41 +01:00
parent e1f786311a
commit 554eb0b122
994 changed files with 195567 additions and 0 deletions

11
node_modules/ps-tree/CHANGELOG.md generated vendored Normal file
View file

@ -0,0 +1,11 @@
# CHANGELOG
## 1.2.0
- [#24] Improve performance
- [#27] Make tests deterministic
- [#29] Improve CI configurations
## 1.1.1
- [#34] Locks `event-stream` to `3.3.4`.

21
node_modules/ps-tree/LICENSE generated vendored Normal file
View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Domenic Tarr, Charlie Robbins & the Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

81
node_modules/ps-tree/README.md generated vendored Normal file
View file

@ -0,0 +1,81 @@
# ps-tree
[![Build Status](https://travis-ci.org/indexzero/ps-tree.svg)](https://travis-ci.org/indexzero/ps-tree)
[![Code Climate](https://codeclimate.com/github/indexzero/ps-tree/badges/gpa.svg)](https://codeclimate.com/github/indexzero/ps-tree)
[![Test Coverage](https://codeclimate.com/github/indexzero/ps-tree/badges/coverage.svg)](https://codeclimate.com/github/indexzero/ps-tree)
[![npm Version](https://img.shields.io/npm/v/ps-tree.svg)](https://www.npmjs.com/package/ps-tree)
[![Node.js Version](https://img.shields.io/node/v/ps-tree.svg?style=flat)](http://nodejs.org/download/)
[![Dependency Status](https://david-dm.org/indexzero/ps-tree.svg)](https://david-dm.org/indexzero/ps-tree)
Sometimes you cannot kill child processes like you would expect, this a feature of UNIX.
>in UNIX, a process may terminate by using the exit call, and it's parent process may wait for that event by using the wait system call. the wait system call returns the process identifier of a terminated child, so that the parent tell which of the possibly many children has terminated. If the parent terminates, however, all it's children have assigned as their new parent the init process. Thus, the children still have a parent to collect their status and execution statistics.
> (from "operating system concepts")
Solution: use `ps-tree` to get all processes that a `child_process` may have started, so that they may all be terminated.
``` js
var cp = require('child_process'),
psTree = require('ps-tree');
var child = cp.exec("node -e 'while (true);'", function () {...});
// This will not actually kill the child it will kill the `sh` process.
child.kill();
```
wtf? it's because exec actually works like this:
``` js
function exec (cmd, cb) {
spawn('sh', ['-c', cmd]);
...
}
```
`sh` starts parses the command string and starts processes, and waits for them to terminate, but `exec` returns a process object with the pid of the `sh` process.
However, since it is in `wait` mode killing it does not kill the children.
Use `ps-tree` like this:
``` js
var cp = require('child_process'),
psTree = require('ps-tree');
var child = cp.exec("node -e 'while (true);'", function () { /*...*/ });
psTree(child.pid, function (err, children) {
cp.spawn('kill', ['-9'].concat(children.map(function (p) { return p.PID })));
});
```
If you prefer to run **psTree** from the command line, use: `node ./bin/ps-tree.js`
## Cross Platform support
The `ps-tree` module behaves differently on *nix vs. Windows by spawning different programs and parsing their output. This is based on `process.platform` and not on checking to see if a `ps` compatible program exists on the system.
#### *nix
1. " <defunct> " need to be striped
```bash
$ ps -A -o comm,ppid,pid,stat
COMMAND PPID PID STAT
bbsd 2899 16958 Ss
watch <defunct> 1914 16964 Z
ps 20688 16965 R+
```
### Windows
1. `wmic PROCESS WHERE ParentProcessId=4604 GET Name,ParentProcessId,ProcessId,Status)`
2. The order of head columns is fixed
```shell
> wmic PROCESS GET Name,ProcessId,ParentProcessId,Status
Name ParentProcessId ProcessId Status
System Idle Process 0 0
System 0 4
smss.exe 4 228
```
### LICENSE: MIT

16
node_modules/ps-tree/bin/ps-tree.js generated vendored Executable file
View file

@ -0,0 +1,16 @@
#!/usr/bin/env node
'use strict';
//
// Change the default parent PID if running
// under Windows.
//
var ppid = 1;
if (process.platform === 'win32') {
ppid = 0;
}
require('../')(process.argv[2] || ppid, function (err, data) {
console.log(data);
});

119
node_modules/ps-tree/index.js generated vendored Executable file
View file

@ -0,0 +1,119 @@
'use strict';
var spawn = require('child_process').spawn,
es = require('event-stream');
module.exports = function childrenOfPid(pid, callback) {
var headers = null;
if (typeof callback !== 'function') {
throw new Error('childrenOfPid(pid, callback) expects callback');
}
if (typeof pid === 'number') {
pid = pid.toString();
}
//
// The `ps-tree` module behaves differently on *nix vs. Windows
// by spawning different programs and parsing their output.
//
// Linux:
// 1. " <defunct> " need to be striped
// ```bash
// $ ps -A -o comm,ppid,pid,stat
// COMMAND PPID PID STAT
// bbsd 2899 16958 Ss
// watch <defunct> 1914 16964 Z
// ps 20688 16965 R+
// ```
//
// Win32:
// 1. wmic PROCESS WHERE ParentProcessId=4604 GET Name,ParentProcessId,ProcessId,Status)
// 2. The order of head columns is fixed
// ```shell
// > wmic PROCESS GET Name,ProcessId,ParentProcessId,Status
// Name ParentProcessId ProcessId Status
// System Idle Process 0 0
// System 0 4
// smss.exe 4 228
// ```
var processLister;
if (process.platform === 'win32') {
// See also: https://github.com/nodejs/node-v0.x-archive/issues/2318
processLister = spawn('wmic.exe', ['PROCESS', 'GET', 'Name,ProcessId,ParentProcessId,Status']);
} else {
processLister = spawn('ps', ['-A', '-o', 'ppid,pid,stat,comm']);
}
es.connect(
// spawn('ps', ['-A', '-o', 'ppid,pid,stat,comm']).stdout,
processLister.stdout,
es.split(),
es.map(function (line, cb) { //this could parse alot of unix command output
var columns = line.trim().split(/\s+/);
if (!headers) {
headers = columns;
//
// Rename Win32 header name, to as same as the linux, for compatible.
//
headers = headers.map(normalizeHeader);
return cb();
}
var row = {};
// For each header
var h = headers.slice();
while (h.length) {
row[h.shift()] = h.length ? columns.shift() : columns.join(' ');
}
return cb(null, row);
}),
es.writeArray(function (err, ps) {
var parents = {},
children = [];
parents[pid] = true;
ps.forEach(function (proc) {
if (parents[proc.PPID]) {
parents[proc.PID] = true;
children.push(proc)
}
});
callback(null, children);
})
).on('error', callback)
}
/**
* Normalizes the given header `str` from the Windows
* title to the *nix title.
*
* @param {string} str Header string to normalize
*/
function normalizeHeader(str) {
if (process.platform !== 'win32') {
return str;
}
switch (str) {
case 'Name':
return 'COMMAND';
break;
case 'ParentProcessId':
return 'PPID';
break;
case 'ProcessId':
return 'PID';
break;
case 'Status':
return 'STAT';
break;
default:
throw new Error('Unknown process listing header: ' + str);
}
}

49
node_modules/ps-tree/package.json generated vendored Normal file
View file

@ -0,0 +1,49 @@
{
"name": "ps-tree",
"version": "1.2.0",
"description": "Get all children of a pid",
"license": "MIT",
"homepage": "http://github.com/indexzero/ps-tree#readme",
"repository": "github:indexzero/ps-tree",
"bugs": {
"url": "https://github.com/indexzero/ps-tree/issues",
"email": "charlie.robbins@gmail.com"
},
"author": "Charlie Robbins <charlie.robbins@gmail.com>",
"contributors": [
"Zhuohuan LI <zixia@zixia.net> (https://github.com/zixia)",
"Simone Primarosa <simonepri@outlook.com> (https://github.com/simonepri)"
],
"keyboards": [
"ps-tree",
"ps",
"tree",
"ppid",
"pid"
],
"main": "index.js",
"bin": {
"ps-tree": "./bin/ps-tree.js"
},
"files": [
"bin",
"index.js"
],
"engines": {
"node": ">= 0.10"
},
"scripts": {
"test": "istanbul cover node_modules/tape/bin/tape test/test.js",
"coverage": "cross-env CODECLIMATE_REPO_TOKEN=84436b4f13c70ace9c62e7f04928bf23c234eb212c0232d39d7fb1535beb2da5 node_modules/.bin/codeclimate-test-reporter < coverage/lcov.info"
},
"dependencies": {
"event-stream": "=3.3.4"
},
"devDependencies": {
"codeclimate-test-reporter": "^0.5.0",
"cross-env": "^2.0.1",
"istanbul": "^0.4.5",
"tape": "^4.9.0",
"tree-kill": "^1.1.0"
}
}