From 679f5c352309ad118b31d8fdb629ee3f2adf410b Mon Sep 17 00:00:00 2001 From: Martin Wimpress Date: Wed, 3 Jul 2024 11:31:19 +0100 Subject: [PATCH] fix: check for running VM processes using kill -0 --- lib/src/pages/manager.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/src/pages/manager.dart b/lib/src/pages/manager.dart index 52a2614..c61d7f9 100644 --- a/lib/src/pages/manager.dart +++ b/lib/src/pages/manager.dart @@ -156,8 +156,10 @@ class _ManagerState extends State with PreferencesMixin { File pidFile = File('$name/$name.pid'); if (pidFile.existsSync()) { String pid = pidFile.readAsStringSync().trim(); - Directory procDir = Directory('/proc/$pid'); - if (procDir.existsSync()) { + // Check if the process is still running using kill -0, which is + // 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)) { activeVms[name] = _activeVms[name]!; } else {