{"_id":"tinyps@0.5.2","bugs":{"url":"https://github.com/tinylibs/tinyps/issues"},"dist":{"shasum":"22b2599eccca21c6e79cde61dc5bcdb8a9ad5c7f","tarball":"http://registry-npm.ywwl.com/tinyps/download/tinyps-0.5.2.tgz","integrity":"sha512-sYhvdbpuo2rGE7u/jPUMiZz4H2LCaOodUtRD9ot4DLNFQbr884g9zozoJnxLI+1r4hXqWkmdHUl8Yig2Rllxxw==","fileCount":7,"unpackedSize":16983,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/tinyps@0.5.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICg/nuBSXHqR4Q9ENYKvmtteLnYXSnPwnMcD8q7TpIfdAiEAqPUyd0zxHqW5LnoL1lGkH9svyfi1Cb9qTqn1P5AlrXY="}],"size":5769,"noattachment":false,"key":"/tinyps/-/tinyps-0.5.2.tgz"},"main":"./lib/main.js","name":"tinyps","type":"module","types":"./lib/main.d.ts","author":{"url":"https://github.com/43081j","name":"James Garbutt"},"exports":{".":{"types":"./lib/main.d.ts","default":"./lib/main.js"}},"gitHead":"f64fe7ad2c6178a1ea153f38a2bb19f282d48ae8","license":"MIT","scripts":{"lint":"npm run lint:js && npm run lint:format","test":"vitest run","build":"npm run build:clean && tsgo","format":"oxfmt --write src","lint:js":"oxlint src","build:clean":"node -e \"require('fs').rmSync('./lib', { recursive: true, force: true })\"","lint:format":"oxfmt --check src"},"version":"0.5.2","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"0788222f-e220-4505-8bc1-c16750b7f929"},"approver":{"name":"43081j","email":"43081james@gmail.com"}},"homepage":"https://github.com/tinylibs/tinyps#readme","keywords":["proc","process","tree-kill","ps-tree","tiny","kill","tree"],"repository":{"url":"git+https://github.com/tinylibs/tinyps.git","type":"git"},"_npmVersion":"12.2.2","description":"A library of utilities for dealing with system processes.","directories":{},"maintainers":[{"name":"43081j","email":"43081james@gmail.com"}],"_nodeVersion":"24.22.2","publishConfig":{"access":"public"},"devDependencies":{"oxfmt":"^0.75.0","oxlint":"^1.90.0","vitest":"^5.0.0","@types/node":"^26.6.6","@vitest/coverage-v8":"^5.0.5","@typescript/native-preview":"^7.0.0-dev.20260509.2"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/tinyps_0.5.2_1793990226952_0.22612053660842402"},"_hasShrinkwrap":false,"readme":"# ⚙️ tinyps\n\nA cross-platform library of utilities for dealing with system processes.\n\n## Install\n\n```sh\nnpm install tinyps\n```\n\n## Usage\n\n```ts\nimport { killTree, getProcessTree, getProcessAncestry } from 'tinyps';\n\n// kill a process and everything it spawned\nawait killTree(child.pid);\n\n// or inspect the tree first\nconst tree = await getProcessTree(child.pid);\nconsole.log(tree.get(child.pid)); // [ 1234, 1235 ]\n\n// trace a process's parent chain back to the root\nconst ancestry = await getProcessAncestry(child.pid);\nconsole.log(ancestry.map((proc) => proc.pid)); // [ childPid, parentPid, ... ]\n```\n\n## API\n\n### `killTree(pid, signal?)`\n\n- `pid` (`number`) - process to kill, along with all of its descendants\n- `signal` (`NodeJS.Signals`, optional) - signal to send, defaults to `SIGTERM`\n- Returns `Promise<void>`\n\nNote that `signal` is not supported on Windows, and will be ignored.\n\n### `getProcessTree(pid)`\n\n- `pid` (`number`) - process to build the tree from\n- Returns `Promise<ProcessTree>`\n\n### `isRunning(pid)`\n\n- `pid` (`number`) - process to check\n- Returns `boolean`\n\nA zombie process is still in the process table, so this returns `true` for a\nprocess which has exited but has not yet been released by its parent.\n\n### `getDescendants(pid)`\n\n- `pid` (`number`) - process to collect descendants of\n- Returns `Promise<number[]>`\n\n### `getProcessAncestry(pid?)`\n\n- `pid` (`number`, optional) - process to trace ancestry from, defaults to `process.pid`\n- Returns `Promise<ProcessInfo[]>`\n\nReturns an ordered list of process info objects starting from the target process and traversing upward through its parents to the root process.\n\n**Note:** On Windows, a parent may have exited and had its pid reassigned. In that case, the ancestry may contain unrelated processes.\n\n### `listProcesses()`\n\n- Returns `Promise<ProcessInfo[]>`\n\n### `getProcessInfo(pid)`\n\n- `pid` (`number`) - process to look up\n- Returns `Promise<ProcessInfo | undefined>`\n\n### `findProcessesByName(name, options?)`\n\n- `name` (`string`) - name to match against\n- `options.loose` (`boolean`, optional) - match any name containing `name`, ignoring case\n- Returns `Promise<ProcessInfo[]>`\n\nNames come from the process' `argv[0]`, so a process which has renamed itself\n(e.g. via `process.title`) matches its new name rather than its executable.\n\n### `findProcessesByPort(port, options?)`\n\n- `port` (`number`) - local port to match against\n- `options.protocol` (`'tcp' | 'udp'`, optional) - only match sockets of this\n  protocol, defaults to matching both\n- Returns `Promise<ProcessInfo[]>`\n\nMatches any process holding a socket bound to `port` locally, whether it is\nlistening or connected.\n\n## License\n\nMIT\n","publish_time":1793990227074,"_cnpm_publish_time":1793990227074,"dist-tags":{"latest":"0.5.2"}}