processCommand function
The command line of process pid, or null when it is gone or cannot be read.
Implementation
Future<String?> processCommand(int pid) async {
try {
final r =
await runBounded('ps', ['-o', 'command=', '-p', '$pid'], timeout: const Duration(seconds: 2), phase: 'ps');
final out = (r.stdout as String).trim();
return r.exitCode == 0 && out.isNotEmpty ? out : null;
} on Object {
return null;
}
}