From: Darold Gilles Date: Mon, 18 Apr 2016 17:15:01 +0000 (+0200) Subject: Fix case where pid file remain after dying. X-Git-Tag: v8.1~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2a72f479d592e0b888b02741bc43a86da5db5e76;p=pgbadger Fix case where pid file remain after dying. --- diff --git a/pgbadger b/pgbadger old mode 100644 new mode 100755 index c1b6233..d89775a --- a/pgbadger +++ b/pgbadger @@ -462,14 +462,14 @@ if (-e "$PID_DIR/pgbadger.pid") { unlink("$PID_DIR/pgbadger.pid"); } else { print "FATAL: an other process is already started or remove the file, see $PID_DIR/pgbadger.pid\n"; - exit 1; + exit 3; } } # Create pid file unless(open(OUT, ">$PID_DIR/pgbadger.pid")) { print "FATAL: can't create pid file $PID_DIR/pgbadger.pid, $!\n"; - exit 1; + exit 3; } print OUT $$; close(OUT); @@ -570,7 +570,12 @@ if ($logfile_list) { # Logfile is a mandatory parameter when journalctl command is not set. if ( !$rebuild && ($#log_files < 0) && !$journalctl_cmd) { - localdie("FATAL: you must give a log file as command line parameter.\n\n"); + if (!$quiet) { + localdie("FATAL: you must give a log file at command line parameter.\n\n"); + } else { + unlink("$PID_DIR/pgbadger.pid"); + exit 4; + } } # Remove follow option from journalctl command to prevent infinit loop