Changeset c203f3d61063c12a4ce36e097772325e4ca8f26f
- Timestamp:
- 03/22/07 03:57:51
(6 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
| r3596d9c |
rc203f3d |
|
| 5 | 5 | use strict; |
|---|
| 6 | 6 | use Time::HiRes qw( gettimeofday tv_interval sleep ); |
|---|
| 7 | | use Data::Dumper; |
|---|
| 8 | 7 | use POSIX qw( setsid ); |
|---|
| 9 | 8 | use Getopt::Long; |
|---|
| | 9 | use Data::Dumper; |
|---|
| 10 | 10 | use vars qw($config_file $debug $status_file $config); |
|---|
| 11 | 11 | |
|---|
| … | … | |
| 29 | 29 | print Dumper($config) if($debug); |
|---|
| 30 | 30 | } |
|---|
| | 31 | |
|---|
| | 32 | $SIG{'HUP'} = \&configure; |
|---|
| | 33 | configure(); |
|---|
| | 34 | |
|---|
| 31 | 35 | unless($debug) { |
|---|
| 32 | 36 | fork && exit; |
|---|
| 33 | 37 | setsid; |
|---|
| | 38 | close(STDIN); |
|---|
| | 39 | close(STDOUT); |
|---|
| | 40 | close(STDERR); |
|---|
| | 41 | fork && exit; |
|---|
| 34 | 42 | } |
|---|
| 35 | | configure(); |
|---|
| 36 | | $SIG{'HUP'} = \&configure; |
|---|
| 37 | 43 | |
|---|
| 38 | | use Time::HiRes qw( gettimeofday tv_interval sleep ); |
|---|
| | 44 | my $sigint = 0; |
|---|
| | 45 | sub sigint_handler { $sigint = 1; } |
|---|
| | 46 | $SIG{'INT'} = \&sigint_handler; |
|---|
| 39 | 47 | |
|---|
| 40 | 48 | my $rmlast = undef; |
|---|
| … | … | |
| 69 | 77 | } |
|---|
| 70 | 78 | $status->close(); |
|---|
| | 79 | die "Exiting.\n" if($sigint); |
|---|
| 71 | 80 | wait_interval(); |
|---|
| | 81 | die "Exiting.\n" if($sigint); |
|---|
| 72 | 82 | print "\n---- ".localtime(time)."----------\n" |
|---|
| 73 | | unless $status->open(); |
|---|
| | 83 | unless $status->open(); |
|---|
| 74 | 84 | } |
|---|
| 75 | 85 | |
|---|