Changeset c203f3d61063c12a4ce36e097772325e4ca8f26f

Show
Ignore:
Timestamp:
03/22/07 03:57:51 (8 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1174535871 +0000
git-parent:

[ac558e1e007de65993818ce12f6a20e22f10c1bb]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1174535871 +0000
Message:

more sane signal handling

git-svn-id: https://labs.omniti.com/resmon/trunk@24 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • resmon

    r3596d9c rc203f3d  
    55use strict; 
    66use Time::HiRes qw( gettimeofday tv_interval sleep ); 
    7 use Data::Dumper; 
    87use POSIX qw( setsid ); 
    98use Getopt::Long; 
     9use Data::Dumper; 
    1010use vars qw($config_file $debug $status_file $config); 
    1111 
     
    2929  print Dumper($config) if($debug); 
    3030} 
     31 
     32$SIG{'HUP'} = \&configure; 
     33configure(); 
     34 
    3135unless($debug) { 
    3236  fork && exit; 
    3337  setsid; 
     38  close(STDIN); 
     39  close(STDOUT); 
     40  close(STDERR); 
     41  fork && exit; 
    3442} 
    35 configure(); 
    36 $SIG{'HUP'} = \&configure; 
    3743 
    38 use Time::HiRes qw( gettimeofday tv_interval sleep ); 
     44my $sigint = 0; 
     45sub sigint_handler { $sigint = 1; } 
     46$SIG{'INT'} = \&sigint_handler; 
    3947 
    4048my $rmlast = undef; 
     
    6977  } 
    7078  $status->close(); 
     79  die "Exiting.\n" if($sigint); 
    7180  wait_interval(); 
     81  die "Exiting.\n" if($sigint); 
    7282  print "\n---- ".localtime(time)."----------\n" 
    73     unless $status->open(); 
     83   unless $status->open(); 
    7484} 
    7585