forked from sindresorhus/ps-list
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
76 lines (57 loc) · 1.5 KB
/
index.d.ts
File metadata and controls
76 lines (57 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
export type Options = {
/**
Include other users' processes as well as your own.
On Windows this has no effect and will always be all users' processes.
@default true
*/
readonly all?: boolean;
};
export type ProcessDescriptor = {
readonly pid: number;
readonly name: string;
readonly ppid: number;
/**
Full command line with arguments.
Not supported on Windows.
*/
readonly cmd?: string;
/**
CPU usage as a percentage (0-100).
Not supported on Windows.
*/
readonly cpu?: number;
/**
Memory usage as a percentage (0-100).
Not supported on Windows.
*/
readonly memory?: number;
/**
User ID of the process owner.
Not supported on Windows.
*/
readonly uid?: number;
/**
Best-effort attempt to get the full executable path.
- Linux: Reads from `/proc/{pid}/exe` when available
- macOS: Extracted from command line when possible
- Falls back to `comm` (which may be truncated)
Not supported on Windows.
*/
readonly path?: string;
/**
The date and time when the process was started.
Not supported on Windows. May be `undefined` if the date cannot be parsed.
*/
readonly startTime?: Date;
};
/**
Get running processes.
@returns A list of running processes.
@example
```
import psList from 'ps-list';
console.log(await psList());
//=> [{pid: 3213, name: 'node', cmd: 'node test.js', ppid: 1, uid: 501, cpu: 0.1, memory: 1.5, path: '/usr/local/bin/node', startTime: 2025-01-15T10:30:00.000Z}, …]
```
*/
export default function psList(options?: Options): Promise<ProcessDescriptor[]>;