Socket
Socket
Sign inDemoInstall

pidtree

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    pidtree

Cross platform children list of a PID


Version published
Weekly downloads
7.8M
decreased by-10.25%
Maintainers
1
Install size
8.63 kB
Created
Weekly downloads
 

Package description

What is pidtree?

The pidtree npm package is a Node.js module that allows you to list all running processes in a hierarchical tree structure based on their process IDs (PIDs). It can be used to find parent and child processes of a given PID, which is useful for monitoring and managing system processes programmatically.

What are pidtree's main functionalities?

Get an array of all running processes as a tree

This code sample demonstrates how to retrieve a tree of all running processes. The '-1' argument specifies that the tree should start with the root process. The callback function receives the tree structure or an error.

const pidtree = require('pidtree');
pidtree(-1, function (err, tree) {
  if (err) throw err;
  console.log(tree);
});

Get a tree of child processes for a specific PID

This code sample shows how to get a tree of child processes for a specific PID. Replace '1234' with the PID of the process you want to inspect. The callback function will receive the tree of child processes or an error.

const pidtree = require('pidtree');
const pid = 1234; // Replace with the target PID
pidtree(pid, function (err, tree) {
  if (err) throw err;
  console.log(tree);
});

Other packages similar to pidtree

Readme

Source

pidtree

Mac/Linux Build Status Windows Build status Codecov Coverage report Known Vulnerabilities Dependency Status
XO Code Style used AVA Test Runner used Istanbul Test Coverage used NI Scaffolding System used NP Release System used
Latest version on npm Project license

🚸 Cross platform children list of a PID.
Coded with ❤️ by Simone Primarosa.

Motivation

The only package that does this simple but tricky job is ps-tree but the project is unmaintained and furthermore the logic is wrong.

Usage

var pidtree = require('pidtree')

// Get childs of current process
pidtree(process.pid, function (err, stat) {
  console.log(stat)
  // => []
})

// Include the given pid in the result array
pidtree(process.pid, {root: true}, function (err, stat) {
  console.log(stat)
  // => [727]
})

// Get all the processes of the System on *nix
pidtree(1, function (err, stat) {
  console.log(stat)
  // => [41,45,43,530,47,50, ..., 41241, 32]
})

Compatibility

LinuxFreeBSDNetBSDSunOSmacOSWinAIX

✅ = Working ❓ = Not tested but should work

Please if your platform is not supported file an issue.

API

pidtree(pids, callback)

Get pid informations.

Kind: global function
Access: public

ParamTypeDefaultDescription
pidsNumber | StringA pid.
optionsObjectOptional options object.
options.rootBooleanfalseInclude the provided pid in the list.
callbackpidCallbackCalled when the list is ready.

pidCallback : function

Kind: global typedef

ParamTypeDescription
errErrorA possible error.
statisticsArray.The array containing the child pids.
  • pidusage - Cross-platform process cpu % and memory usage of a PID

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the license file for details.

FAQs

Last updated on 19 Mar 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc