From c050b32b203ed3bdebe04d5fc9b34498f0bcad90 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Tue, 18 Oct 2011 16:33:50 +0200 Subject: [PATCH] bin/qasim-gui: Fix other process detection using /proc instead of kill. --- bin/qasim-gui.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bin/qasim-gui.rb b/bin/qasim-gui.rb index 0cf8ac7..f7bf19d 100755 --- a/bin/qasim-gui.rb +++ b/bin/qasim-gui.rb @@ -225,10 +225,15 @@ module Qasim # test if the other process still exist masterpid = File.read(lockfname).strip begin - Process.kill(0, masterpid.to_i) - warn "error: Another instance of %s is already running." % APP_NAME - exit 1 - rescue Errno::ESRCH => e + # FIXME: test if the other process exists + other_path = "/proc/#{masterpid.to_i}" + if File.exists? other_path then + cmdline = File.read( File.join( other_path, 'cmdline' ) ) + if cmdline =~ /qasim/ then + warn "error: Another instance of %s is already running." % APP_NAME + exit 1 + end + end fd = IO::sysopen( lockfname, Fcntl::O_WRONLY | Fcntl::O_EXCL ) f = IO.open(fd)