Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,15 @@ System 0 4
smss.exe 4 228
```

### Mac/Darwin

1. " " need to be striped

```shell
$ ps -A -o comm,ppid,pid,stat
COMM PPID PID STAT
/sbin/launchd 0 1 Ss
/usr/libexec/Use 1 43 Ss
```

### LICENSE: MIT
Empty file modified bin/ps-tree.js
100644 → 100755
Empty file.
15 changes: 9 additions & 6 deletions index.js
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ module.exports = function childrenOfPid(pid, callback) {
// ps 20688 16965 R+
// ```
//
// Darwin:
// $ ps -A -o comm,ppid,pid,stat
// COMM PPID PID STAT
// /sbin/launchd 0 1 Ss
// /usr/libexec/Use 1 43 Ss
//
// Win32:
// 1. wmic PROCESS WHERE ParentProcessId=4604 GET Name,ParentProcessId,ProcessId,Status)
// 2. The order of head columns is fixed
Expand Down Expand Up @@ -95,12 +101,9 @@ module.exports = function childrenOfPid(pid, callback) {
* @param {string} str Header string to normalize
*/
function normalizeHeader(str) {
if (process.platform !== 'win32') {
return str;
}

switch (str) {
case 'Name':
case 'Name': // for win32
case 'COMM': // for darwin
return 'COMMAND';
break;
case 'ParentProcessId':
Expand All @@ -113,6 +116,6 @@ function normalizeHeader(str) {
return 'STAT';
break;
default:
throw new Error('Unknown process listing header: ' + str);
return str
}
}