findByExecutable static method

Future<List<int>> findByExecutable(
  1. String executable
)

The pids of the running processes of executable (the path of an executable file, relative to the current directory or absolute), empty when none.

Linux and Windows compare the executable of each process (a process of an executable replaced since is found too on Linux), only for the processes of the current user; macOS compares the command line of each process (the executable started by its path, the way Process.start does), the processes of every user. The current process may be one of them.

Implementation

static Future<List<int>> findByExecutable(String executable) async {
  var paths = _executablePaths(executable);
  return [
    for (var entry in await readProcessTable())
      if (_entryRunsExecutable(entry, paths)) entry.pid,
  ];
}