{"id":13474124,"url":"https://github.com/simonepri/pidtree","last_synced_at":"2025-04-12T18:44:28.669Z","repository":{"id":30707731,"uuid":"125794606","full_name":"simonepri/pidtree","owner":"simonepri","description":"🚸 Cross platform children list of a PID.","archived":false,"fork":false,"pushed_at":"2022-12-13T08:46:35.000Z","size":51,"stargazers_count":124,"open_issues_count":8,"forks_count":14,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-03T21:11:32.729Z","etag":null,"topics":["cli","list","nodejs","pgrep","pid","pids","ppid","ps","ps-tree","tree"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simonepri.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-19T03:09:54.000Z","updated_at":"2025-03-16T01:49:17.000Z","dependencies_parsed_at":"2023-01-14T17:31:16.862Z","dependency_job_id":null,"html_url":"https://github.com/simonepri/pidtree","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonepri%2Fpidtree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonepri%2Fpidtree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonepri%2Fpidtree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonepri%2Fpidtree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonepri","download_url":"https://codeload.github.com/simonepri/pidtree/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247535513,"owners_count":20954576,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","list","nodejs","pgrep","pid","pids","ppid","ps","ps-tree","tree"],"created_at":"2024-07-31T16:01:09.709Z","updated_at":"2025-04-12T18:44:28.647Z","avatar_url":"https://github.com/simonepri.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003cb\u003epidtree\u003c/b\u003e\n\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n  \u003c!-- Version - npm --\u003e\n  \u003ca href=\"https://www.npmjs.com/package/pidtree\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/pidtree.svg\" alt=\"Latest version on npm\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Downloads - npm --\u003e\n  \u003ca href=\"https://npm-stat.com/charts.html?package=pidtree\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dt/pidtree.svg\" alt=\"Downloads on npm\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- License - MIT --\u003e\n  \u003ca href=\"https://github.com/simonepri/pidtree/tree/master/license\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/simonepri/pidtree.svg\" alt=\"Project license\" /\u003e\n  \u003c/a\u003e\n\n  \u003cbr/\u003e\n\n  \u003c!-- Lint --\u003e\n  \u003ca href=\"https://github.com/simonepri/pidtree/actions?query=workflow:lint+branch:master\"\u003e\n    \u003cimg src=\"https://github.com/simonepri/pidtree/workflows/lint/badge.svg?branch=master\" alt=\"Lint status\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Test - macOS --\u003e\n  \u003ca href=\"https://github.com/simonepri/pidtree/actions?query=workflow:test-macos+branch:master\"\u003e\n    \u003cimg src=\"https://github.com/simonepri/pidtree/workflows/test-macos/badge.svg?branch=master\" alt=\"Test macOS status\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Test - Ubuntu --\u003e\n  \u003ca href=\"https://github.com/simonepri/pidtree/actions?query=workflow:test-ubuntu+branch:master\"\u003e\n    \u003cimg src=\"https://github.com/simonepri/pidtree/workflows/test-ubuntu/badge.svg?branch=master\" alt=\"Test Ubuntu status\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Test - Windows --\u003e\n  \u003ca href=\"https://github.com/simonepri/pidtree/actions?query=workflow:test-windows+branch:master\"\u003e\n    \u003cimg src=\"https://github.com/simonepri/pidtree/workflows/test-windows/badge.svg?branch=master\" alt=\"Test Windows status\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Coverage - Codecov --\u003e\n  \u003ca href=\"https://codecov.io/gh/simonepri/pidtree\"\u003e\n    \u003cimg src=\"https://img.shields.io/codecov/c/github/simonepri/pidtree/master.svg\" alt=\"Codecov Coverage report\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- DM - Snyk --\u003e\n  \u003ca href=\"https://snyk.io/test/github/simonepri/pidtree?targetFile=package.json\"\u003e\n    \u003cimg src=\"https://snyk.io/test/github/simonepri/pidtree/badge.svg?targetFile=package.json\" alt=\"Known Vulnerabilities\" /\u003e\n  \u003c/a\u003e\n\n  \u003cbr/\u003e\n\n  \u003c!-- Code Style - XO-Prettier --\u003e\n  \u003ca href=\"https://github.com/xojs/xo\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/code_style-XO+Prettier-5ed9c7.svg\" alt=\"XO Code Style used\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Test Runner - AVA --\u003e\n  \u003ca href=\"https://github.com/avajs/ava\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/test_runner-AVA-fb3170.svg\" alt=\"AVA Test Runner used\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Test Coverage - Istanbul --\u003e\n  \u003ca href=\"https://github.com/istanbuljs/nyc\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/test_coverage-NYC-fec606.svg\" alt=\"Istanbul Test Coverage used\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Init - ni --\u003e\n  \u003ca href=\"https://github.com/simonepri/ni\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/initialized_with-ni-e74c3c.svg\" alt=\"NI Scaffolding System used\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Release - np --\u003e\n  \u003ca href=\"https://github.com/sindresorhus/np\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/released_with-np-6c8784.svg\" alt=\"NP Release System used\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  🚸 Cross platform children list of a PID.\n\n  \u003cbr/\u003e\n\n  \u003csub\u003e\n    Coded with ❤️ by \u003ca href=\"#authors\"\u003eSimone Primarosa\u003c/a\u003e.\n  \u003c/sub\u003e\n\u003c/p\u003e\n\n## Synopsis\n\nThis package is really similar to [ps-tree][gh:ps-tree] but is faster, safer and\nprovides sub-children results.  \nFurthermore ps-tree is [unmaintained][gh:ps-tree-um].\n\nUuh, and a fancy [CLI](#cli) is also available!\n\n## Usage\n\n```js\nvar pidtree = require('pidtree')\n\n// Get childs of current process\npidtree(process.pid, function (err, pids) {\n  console.log(pids)\n  // =\u003e []\n})\n\n// Include the given pid in the result array\npidtree(process.pid, {root: true}, function (err, pids) {\n  console.log(pids)\n  // =\u003e [727]\n})\n\n// Get all the processes of the System (-1 is a special value of this package)\npidtree(-1, function (err, pids) {\n  console.log(pids)\n  // =\u003e [530, 42, ..., 41241]\n})\n\n// Include PPID in the results\npidtree(1, {advanced: true}, function (err, pids) {\n  console.log(pids)\n  // =\u003e [{ppid: 1, pid: 530}, {ppid: 1, pid: 42}, ..., {ppid: 1, pid: 41241}]\n})\n\n// If no callback is given it returns a promise instead\nconst pids = await pidtree(1)\nconsole.log(pids)\n// =\u003e [141, 42, ..., 15242]\n```\n\n## Compatibility\n\n| Linux | FreeBSD | NetBSD | SunOS | macOS | Win | AIX |\n| --- | --- | --- | --- | --- | --- | --- |\n| ✅ | ❓ | ❓ | ❓ | ✅ | ✅ | ❓ |\n\n✅ = Working\n❓ = Not tested but should work\n\nPlease if your platform is not supported [file an issue][new issue].\n\n## CLI\n\n\u003cimg src=\"https://github.com/simonepri/pidtree/raw/master/media/cli.gif\" alt=\"pidtree cli\" width=\"300\" align=\"right\"/\u003e\nShow a tree of the processes inside your system inside your terminal.\n\n```bash\nnpx pidtree $PPID\n```\nJust replace `$PPID` with one of the pids inside your system.\n\nOr don't pass anything if you want all the pids inside your system.\n\n```bash\nnpx pidtree\n```\n\nTo display the output as a list, similar to the one produced from `pgrep -P $PID`,\npass the `--list` flag.\n\n```bash\nnpx pidtree --list\n```\n\n## API\n\n\u003ca name=\"pidtree\"\u003e\u003c/a\u003e\n\n## pidtree(pid, [options], [callback]) ⇒ \u003ccode\u003e[Promise.\u0026lt;Array.\u0026lt;Object\u0026gt;\u0026gt;]\u003c/code\u003e\nGet the list of children pids of the given pid.\n\n**Kind**: global function  \n**Returns**: \u003ccode\u003ePromise.\u0026lt;Array.\u0026lt;Object\u0026gt;\u0026gt;\u003c/code\u003e - Only when the callback is not provided.  \n**Access**: public  \n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| pid | \u003ccode\u003eNumber\u003c/code\u003e \\| \u003ccode\u003eString\u003c/code\u003e |  | A pid. If -1 will return all the pids. |\n| [options] | \u003ccode\u003eObject\u003c/code\u003e |  | Optional options object. |\n| [options.root] | \u003ccode\u003eBoolean\u003c/code\u003e | \u003ccode\u003efalse\u003c/code\u003e | Include the provided pid in the list. Ignored if -1 is passed as pid. |\n| [callback] | \u003ccode\u003efunction\u003c/code\u003e |  | Called when the list is ready. If not provided a promise is returned instead. |\n\n## Related\n\n- [pidusage][gh:pidusage] -\nCross-platform process cpu % and memory usage of a PID\n\n## Authors\n\n- **Simone Primarosa** - [simonepri][github:simonepri]\n\nSee also the list of [contributors][contributors] who participated in this project.\n\n## License\n\nThis project is licensed under the MIT License - see the [license][license] file for details.\n\n\u003c!-- Links --\u003e\n[new issue]: https://github.com/simonepri/pidtree/issues/new\n[license]: https://github.com/simonepri/pidtree/tree/master/license\n[contributors]: https://github.com/simonepri/pidtree/contributors\n\n[github:simonepri]: https://github.com/simonepri\n\n[gh:pidusage]: https://github.com/soyuka/pidusage\n[gh:ps-tree]: https://github.com/indexzero/ps-tree\n[gh:ps-tree-um]: https://github.com/indexzero/ps-tree/issues/30\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonepri%2Fpidtree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonepri%2Fpidtree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonepri%2Fpidtree/lists"}