basant307/AI_Governance_Project
048
1<h1 align="center">2 <b>pidtree</b>3</h1>4<p align="center">5 <!-- CI - TravisCI -->6 <a href="https://travis-ci.org/simonepri/pidtree">7 <img src="https://img.shields.io/travis/simonepri/pidtree/master.svg?label=MacOS%20%26%20Linux" alt="Mac/Linux Build Status" />8 </a>9 <!-- CI - AppVeyor -->10 <a href="https://ci.appveyor.com/project/simonepri/pidtree">11 <img src="https://img.shields.io/appveyor/ci/simonepri/pidtree/master.svg?label=Windows" alt="Windows Build status" />12 </a>13 <!-- Coverage - Codecov -->14 <a href="https://codecov.io/gh/simonepri/pidtree">15 <img src="https://img.shields.io/codecov/c/github/simonepri/pidtree/master.svg" alt="Codecov Coverage report" />16 </a>17 <!-- DM - Snyk -->18 <a href="https://snyk.io/test/github/simonepri/pidtree?targetFile=package.json">19 <img src="https://snyk.io/test/github/simonepri/pidtree/badge.svg?targetFile=package.json" alt="Known Vulnerabilities" />20 </a>21 <!-- DM - David -->22 <a href="https://david-dm.org/simonepri/pidtree">23 <img src="https://david-dm.org/simonepri/pidtree/status.svg" alt="Dependency Status" />24 </a>25 26 <br/>27 28 <!-- Code Style - XO-Prettier -->29 <a href="https://github.com/xojs/xo">30 <img src="https://img.shields.io/badge/code_style-XO+Prettier-5ed9c7.svg" alt="XO Code Style used" />31 </a>32 <!-- Test Runner - AVA -->33 <a href="https://github.com/avajs/ava">34 <img src="https://img.shields.io/badge/test_runner-AVA-fb3170.svg" alt="AVA Test Runner used" />35 </a>36 <!-- Test Coverage - Istanbul -->37 <a href="https://github.com/istanbuljs/nyc">38 <img src="https://img.shields.io/badge/test_coverage-NYC-fec606.svg" alt="Istanbul Test Coverage used" />39 </a>40 <!-- Init - ni -->41 <a href="https://github.com/simonepri/ni">42 <img src="https://img.shields.io/badge/initialized_with-ni-e74c3c.svg" alt="NI Scaffolding System used" />43 </a>44 <!-- Release - np -->45 <a href="https://github.com/sindresorhus/np">46 <img src="https://img.shields.io/badge/released_with-np-6c8784.svg" alt="NP Release System used" />47 </a>48 49 <br/>50 51 <!-- Version - npm -->52 <a href="https://www.npmjs.com/package/pidtree">53 <img src="https://img.shields.io/npm/v/pidtree.svg" alt="Latest version on npm" />54 </a>55 <!-- License - MIT -->56 <a href="https://github.com/simonepri/pidtree/tree/master/license">57 <img src="https://img.shields.io/github/license/simonepri/pidtree.svg" alt="Project license" />58 </a>59</p>60<p align="center">61 ๐ธ Cross platform children list of a PID.62 63 <br/>64 65 <sub>66 Coded with โค๏ธ by <a href="#authors">Simone Primarosa</a>.67 </sub>68</p>69 70## Synopsis71 72This package is really similar to [ps-tree][gh:ps-tree] but is faster, safer and73provides sub-children results. 74Furthermore ps-tree is [unmaintained][gh:ps-tree-um].75 76Uuh, and a fancy [CLI](#cli) is also available!77 78## Usage79 80```js81var pidtree = require('pidtree')82 83// Get childs of current process84pidtree(process.pid, function (err, pids) {85 console.log(pids)86 // => []87})88 89// Include the given pid in the result array90pidtree(process.pid, {root: true}, function (err, pids) {91 console.log(pids)92 // => [727]93})94 95// Get all the processes of the System (-1 is a special value of this package)96pidtree(-1, function (err, pids) {97 console.log(pids)98 // => [530, 42, ..., 41241]99})100 101// Include PPID in the results102pidtree(1, {advanced: true}, function (err, pids) {103 console.log(pids)104 // => [{ppid: 1, pid: 530}, {ppid: 1, pid: 42}, ..., {ppid: 1, pid: 41241}]105})106 107// If no callback is given it returns a promise instead108const pids = await pidtree(1)109console.log(pids)110// => [141, 42, ..., 15242]111```112 113## Compatibility114 115| Linux | FreeBSD | NetBSD | SunOS | macOS | Win | AIX |116| --- | --- | --- | --- | --- | --- | --- |117| โ
| โ | โ | โ | โ
| โ
| โ |118 119โ
= Working120โ = Not tested but should work121 122Please if your platform is not supported [file an issue][new issue].123 124## CLI125 126<img src="https://github.com/simonepri/pidtree/raw/master/media/cli.gif" alt="pidtree cli" width="300" align="right"/>127Show a tree of the processes inside your system inside your terminal.128 129```bash130npx pidtree $PPID131```132Just replace `$PPID` with one of the pids inside your system.133 134Or don't pass anything if you want all the pids inside your system.135 136```bash137npx pidtree138```139 140To display the output as a list, similar to the one produced from `pgrep -P $PID`,141pass the `--list` flag.142 143```bash144npx pidtree --list145```146 147## API148 149<a name="pidtree"></a>150 151## pidtree(pid, [options], [callback]) โ <code>[Promise.<Array.<Object>>]</code>152Get the list of children pids of the given pid.153 154**Kind**: global function 155**Returns**: <code>Promise.<Array.<Object>></code> - Only when the callback is not provided. 156**Access**: public 157 158| Param | Type | Default | Description |159| --- | --- | --- | --- |160| pid | <code>Number</code> \| <code>String</code> | | A pid. If -1 will return all the pids. |161| [options] | <code>Object</code> | | Optional options object. |162| [options.root] | <code>Boolean</code> | <code>false</code> | Include the provided pid in the list. Ignored if -1 is passed as pid. |163| [callback] | <code>function</code> | | Called when the list is ready. If not provided a promise is returned instead. |164 165## Related166 167- [pidusage][gh:pidusage] -168Cross-platform process cpu % and memory usage of a PID169 170## Authors171 172- **Simone Primarosa** - [simonepri][github:simonepri]173 174See also the list of [contributors][contributors] who participated in this project.175 176## License177 178This project is licensed under the MIT License - see the [license][license] file for details.179 180<!-- Links -->181[new issue]: https://github.com/simonepri/pidtree/issues/new182[license]: https://github.com/simonepri/pidtree/tree/master/license183[contributors]: https://github.com/simonepri/pidtree/contributors184 185[github:simonepri]: https://github.com/simonepri186 187[gh:pidusage]: https://github.com/soyuka/pidusage188[gh:ps-tree]: https://github.com/indexzero/ps-tree189[gh:ps-tree-um]: https://github.com/indexzero/ps-tree/issues/30190 