ShellProcesses class abstract final

The processes of the machine by their pid, the way the ps, pgrep and kill commands of a shell handle them: any process, not only the ones a Shell started (an app started from another terminal), on Linux (/proc), macOS (ps) and Windows (PowerShell, tasklist).

A process of another user is seen (isRunning, descendantsOf) but usually not found by its executable (findByExecutable, except on macOS) and cannot be killed (kill, unless root or administrator).

Not to be confused with Shell.kill, which kills the command a shell runs.

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

descendantsOf(int pid) → Future<List<int>>
The pids of the running descendants of pid (its children, their children...), the closest first, empty when none.
findByExecutable(String executable) → Future<List<int>>
The pids of the running processes of executable (the path of an executable file, relative to the current directory or absolute), empty when none.
isRunning(int pid) → Future<bool>
True when the process pid is running: false once exited (a zombie, not reaped yet by its parent, is not running).
kill(Iterable<int> pids, {ProcessSignal signal = io.ProcessSignal.sigterm, bool tree = false, Duration timeout = const Duration(seconds: 5)}) → Future<List<int>>
Kills the processes pids and waits for them to exit: signal (sigterm by default) first, then sigkill for the ones still running after timeout (2 more seconds for these).