mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-12 02:39:57 +00:00
fhem.pl: cleaner code for HUP (Forum #75408)
git-svn-id: https://svn.fhem.de/fhem/trunk@14944 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
996bd70f08
commit
89fa15c25e
13
fhem/fhem.pl
13
fhem/fhem.pl
@ -257,7 +257,7 @@ my $logopened = 0; # logfile opened or using stdout
|
||||
my $namedef = "where <name> is a single device name, a list separated by komma (,) or a regexp. See the devspec section in the commandref.html for details.\n";
|
||||
my $rcvdquit; # Used for quit handling in init files
|
||||
my $readingsUpdateDelayTrigger; # needed internally
|
||||
my $sig_term = 0; # if set to 1, terminate (saving the state)
|
||||
my $gotSig; # non-undef if got a signal
|
||||
my $wbName = ".WRITEBUFFER"; # Buffer-name for delayed writing via select
|
||||
my %comments; # Comments from the include files
|
||||
my %duplicate; # Pool of received msg for multi-fhz/cul setups
|
||||
@ -618,6 +618,7 @@ sub MAIN {MAIN:}; #Dummy
|
||||
|
||||
|
||||
my $errcount= 0;
|
||||
$gotSig = undef if($gotSig && $gotSig eq "HUP");
|
||||
while (1) {
|
||||
my ($rout,$rin, $wout,$win, $eout,$ein) = ('','', '','', '','');
|
||||
|
||||
@ -642,7 +643,11 @@ while (1) {
|
||||
my $nfound = select($rout=$rin, $wout=$win, $eout=$ein, $timeout);
|
||||
|
||||
$winService->{serviceCheck}->() if($winService->{serviceCheck});
|
||||
CommandShutdown(undef, undef) if($sig_term);
|
||||
if($gotSig) {
|
||||
CommandShutdown(undef, undef) if($gotSig eq "TERM");
|
||||
CommandRereadCfg(undef, "") if($gotSig eq "HUP");
|
||||
$gotSig = undef;
|
||||
}
|
||||
|
||||
if($nfound < 0) {
|
||||
my $err = int($!);
|
||||
@ -3105,10 +3110,10 @@ sub
|
||||
SignalHandling()
|
||||
{
|
||||
if($^O ne "MSWin32") {
|
||||
$SIG{TERM} = sub { $sig_term = 1; };
|
||||
$SIG{TERM} = sub { $gotSig = "TERM"; };
|
||||
$SIG{PIPE} = 'IGNORE';
|
||||
$SIG{CHLD} = 'IGNORE';
|
||||
$SIG{HUP} = sub { CommandRereadCfg(undef, "") };
|
||||
$SIG{HUP} = sub { $gotSig = "HUP"; };
|
||||
$SIG{ALRM} = sub { Log 1, "ALARM signal, blocking write?" };
|
||||
#$SIG{'XFSZ'} = sub { Log 1, "XFSZ signal" }; # to test with limit filesize
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user