From a202827d441c3afe2ed81da32593ed2f7397228b Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Thu, 13 Aug 2015 12:58:36 +0300 Subject: Abort cleanly if we cannot acquire our lockfile. This avoids a backtrace, and shows a clean reason for failure. --- lib/byteback/util.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/byteback/util.rb b/lib/byteback/util.rb index 99a5b23..9a993d6 100644 --- a/lib/byteback/util.rb +++ b/lib/byteback/util.rb @@ -35,8 +35,12 @@ module Byteback end # Own the pidfile ourselves - File.open(@@lockfile, 'w') do |lockfile| - lockfile.puts Process.pid + begin + File.open(@@lockfile, 'w') do |lockfile| + lockfile.puts Process.pid + end + rescue => _ex + fatal("Failed to open lockfile - are you running as root?") end end -- cgit v1.2.3