isProcessRunning function
Implementation
Future<bool> isProcessRunning(int pid) async {
if (Platform.isWindows) {
var result = await Process.run(
'powershell',
['ps', '-Id', '$pid'],
runInShell: true,
);
return result.exitCode == 0;
} else if (Platform.isLinux || Platform.isMacOS) {
var result = await Process.run(
'ps',
['$pid'],
runInShell: true,
);
return result.exitCode == 0;
}
throw UnsupportedError(
'Not able to find parent process on ${Platform.operatingSystem}');
}