fix: check for running VM processes using kill -0
This commit is contained in:
parent
ada669500f
commit
679f5c3523
|
@ -156,8 +156,10 @@ class _ManagerState extends State<Manager> with PreferencesMixin {
|
||||||
File pidFile = File('$name/$name.pid');
|
File pidFile = File('$name/$name.pid');
|
||||||
if (pidFile.existsSync()) {
|
if (pidFile.existsSync()) {
|
||||||
String pid = pidFile.readAsStringSync().trim();
|
String pid = pidFile.readAsStringSync().trim();
|
||||||
Directory procDir = Directory('/proc/$pid');
|
// Check if the process is still running using kill -0, which is
|
||||||
if (procDir.existsSync()) {
|
// a portable way to check if a process is running on macOS and Linux.
|
||||||
|
ProcessResult result = Process.runSync('kill', ['-0', pid]);
|
||||||
|
if (result.exitCode == 0) {
|
||||||
if (_activeVms.containsKey(name)) {
|
if (_activeVms.containsKey(name)) {
|
||||||
activeVms[name] = _activeVms[name]!;
|
activeVms[name] = _activeVms[name]!;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue