about summary refs log tree commit homepage
path: root/lib/PublicInbox/Daemon.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-02-29 00:41:02 +0000
committerEric Wong <e@80x24.org>2016-02-29 00:41:02 +0000
commit1c0cfc8726c1c5e4085ad43bdf533b91af88e971 (patch)
tree072d073fbdb1ea20a4ebcf6fee6bd482ba58c8f1 /lib/PublicInbox/Daemon.pm
parente3fd8551e919b95a78f1f0ab0cfff12033291eeb (diff)
downloadpublic-inbox-1c0cfc8726c1c5e4085ad43bdf533b91af88e971.tar.gz
For error messages intended to show user error (e.g. giving
invalid options), we add a newline ("\n") at the end to
polluting the output with location information.

However, for diagnosing non-user-triggered errors, we should
show the location of where the error occured.
Diffstat (limited to 'lib/PublicInbox/Daemon.pm')
-rw-r--r--lib/PublicInbox/Daemon.pm18
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm
index b8482d36..45c15634 100644
--- a/lib/PublicInbox/Daemon.pm
+++ b/lib/PublicInbox/Daemon.pm
@@ -67,12 +67,12 @@ sub daemon_prepare ($) {
                         warn "error binding $l: $!\n";
                 }
         }
-        die 'No listeners bound' unless @listeners;
+        die "No listeners bound\n" unless @listeners;
 }
 
 sub daemonize () {
-        chdir '/' or die "chdir failed: $!\n";
-        open(STDIN, '+<', '/dev/null') or die "redirect stdin failed: $!\n";
+        chdir '/' or die "chdir failed: $!";
+        open(STDIN, '+<', '/dev/null') or die "redirect stdin failed: $!";
 
         return unless (defined $pid_file || defined $group || defined $user
                         || $daemonize);
@@ -238,12 +238,10 @@ sub do_fork () {
         my $new = POSIX::SigSet->new;
         $new->fillset;
         my $old = POSIX::SigSet->new;
-        POSIX::sigprocmask(&POSIX::SIG_BLOCK, $new, $old) or
-                                die "SIG_BLOCK: $!\n";
+        POSIX::sigprocmask(&POSIX::SIG_BLOCK, $new, $old) or die "SIG_BLOCK: $!";
         my $pid = fork;
         my $err = $!;
-        POSIX::sigprocmask(&POSIX::SIG_SETMASK, $old) or
-                                die "SIG_SETMASK: $!\n";
+        POSIX::sigprocmask(&POSIX::SIG_SETMASK, $old) or die "SIG_SETMASK: $!";
         ($pid, $err);
 }
 
@@ -254,7 +252,7 @@ sub upgrade_aborted ($) {
         return unless $pid_file;
 
         my $file = $pid_file;
-        $file =~ s/\.oldbin\z// or die "BUG: no '.oldbin' suffix in $file\n";
+        $file =~ s/\.oldbin\z// or die "BUG: no '.oldbin' suffix in $file";
         unlink_pid_file_safe_ish($$, $pid_file);
         $pid_file = $file;
         eval { write_pid($pid_file) };
@@ -289,8 +287,8 @@ sub unlink_pid_file_safe_ish ($$) {
 }
 
 sub master_loop {
-        pipe(my ($p0, $p1)) or die "failed to create parent-pipe: $!\n";
-        pipe(my ($r, $w)) or die "failed to create self-pipe: $!\n";
+        pipe(my ($p0, $p1)) or die "failed to create parent-pipe: $!";
+        pipe(my ($r, $w)) or die "failed to create self-pipe: $!";
         IO::Handle::blocking($w, 0);
         my $set_workers = $worker_processes;
         my @caught;