qasim-gui: Locker pid testing was buggy. Fixed.

This commit is contained in:
Glenn Y. Rolland 2011-09-16 00:40:12 +02:00
parent 29ed8c2280
commit ed6a74ff47

View file

@ -224,14 +224,18 @@ module Qasim
rescue Errno::EEXIST => e rescue Errno::EEXIST => e
# test if the other process still exist # test if the other process still exist
masterpid = File.read(lockfname).strip masterpid = File.read(lockfname).strip
begin
Process.kill(0, masterpid.to_i) Process.kill(0, masterpid.to_i)
warn "error: Another instance of %s is already running." % APP_NAME warn "error: Another instance of %s is already running." % APP_NAME
exit 1 exit 1
rescue Errno::ESRCH => e rescue Errno::ESRCH => e
fd = IO::sysopen( lockfname,
Fcntl::O_WRONLY | Fcntl::O_EXCL )
f = IO.open(fd) f = IO.open(fd)
f.syswrite( "#{Process.pid}\n" ) f.syswrite( "#{Process.pid}\n" )
f.close f.close
@app.exec @app.exec
end
ensure ensure
masterpid = File.read(lockfname).strip masterpid = File.read(lockfname).strip
if masterpid.to_i == Process.pid then if masterpid.to_i == Process.pid then