Notice errors writing out the PID file and abort
[catagits/FCGI-ProcManager.git] / lib / FCGI / ProcManager.pm
index 0bff7cf..c1c4023 100644 (file)
@@ -13,7 +13,7 @@ use POSIX qw(:signal_h);
 
 use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS $Q $SIG_CODEREF);
 BEGIN {
-  $VERSION = '0.22';
+  $VERSION = '0.24';
   @ISA = qw(Exporter);
   @EXPORT_OK = qw(pm_manage pm_die pm_wait
           pm_write_pid_file pm_remove_pid_file
@@ -335,7 +335,7 @@ sub pm_wait {
   my ($this) = self_or_default(@_);
 
   # wait for the next server to die.
-  return if (my $pid = wait() < 0);
+  return if ((my $pid = wait()) < 0);
 
   # notify when one of our servers have died.
   delete $this->{PIDS}->{$pid} and
@@ -359,12 +359,13 @@ specified, it uses the value of the C<pid_fname> parameter.
 sub pm_write_pid_file {
   my ($this,$fname) = self_or_default(@_);
   $fname ||= $this->pid_fname() or return;
-  if (!open PIDFILE, ">$fname") {
+  my $PIDFILE
+  if (!open $PIDFILE, ">$fname") {
     $this->pm_warn("open: $fname: $!");
     return;
   }
-  print PIDFILE "$$\n";
-  close PIDFILE;
+  print $PIDFILE "$$\n" or die "Could not print PID: $!";
+  close $PIDFILE or die "Could not close PID file";
 }
 
 =head2 pm_remove_pid_file