2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 03:06:37 +00:00

fhem.pl: Fix shutdown exitvalue for delayedshutdown (Forum #102128)

git-svn-id: https://svn.fhem.de/fhem/trunk@19805 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2019-07-09 09:44:07 +00:00
parent 2756e7fdb1
commit 8949425c26

View File

@ -183,7 +183,7 @@ sub CommandSet($$);
sub CommandSetReading($$); sub CommandSetReading($$);
sub CommandSetstate($$); sub CommandSetstate($$);
sub CommandSetuuid($$); sub CommandSetuuid($$);
sub CommandShutdown($$;$$); sub CommandShutdown($$;$$$);
sub CommandSleep($$); sub CommandSleep($$);
sub CommandTrigger($$); sub CommandTrigger($$);
@ -1754,9 +1754,9 @@ CancelDelayedShutdown($)
} }
sub sub
DelayedShutdown($$) DelayedShutdown($$$)
{ {
my ($cl, $param) = @_; my ($cl, $param, $exitValue) = @_;
return 1 if(keys %delayedShutdowns); return 1 if(keys %delayedShutdowns);
foreach my $d (sort keys %defs) { foreach my $d (sort keys %defs) {
@ -1774,7 +1774,7 @@ DelayedShutdown($$)
$checkList = sub() $checkList = sub()
{ {
return CommandShutdown($cl, $param, undef, 1) return CommandShutdown($cl, $param, undef, 1, $exitValue)
if(!keys %delayedShutdowns || $waitingFor++ >= $maxShutdownDelay); if(!keys %delayedShutdowns || $waitingFor++ >= $maxShutdownDelay);
InternalTimer(gettimeofday()+1, $checkList, undef, 0); InternalTimer(gettimeofday()+1, $checkList, undef, 0);
}; };
@ -1783,17 +1783,16 @@ DelayedShutdown($$)
} }
sub sub
CommandShutdown($$;$$) CommandShutdown($$;$$$)
{ {
my ($cl, $param, $cmdName, $final) = @_; my ($cl, $param, $cmdName, $final, $exitValue) = @_;
my $exitValue = 0;
if($param && $param =~ m/^(\d+)$/) { if($param && $param =~ m/^(\d+)$/) {
$exitValue = $1; $exitValue = $1;
$param = ""; $param = "";
} }
return "Usage: shutdown [restart|exitvalue]" return "Usage: shutdown [restart|exitvalue]"
if($param && $param ne "restart"); if($param && $param ne "restart");
return if(!$final && DelayedShutdown($cl, $param)); return if(!$final && DelayedShutdown($cl, $param, $exitValue));
DoTrigger("global", "SHUTDOWN", 1); DoTrigger("global", "SHUTDOWN", 1);
Log 0, "Server shutdown"; Log 0, "Server shutdown";
@ -1813,7 +1812,7 @@ CommandShutdown($$;$$)
exec('cmd.exe /C net stop fhem & net start fhem'); exec('cmd.exe /C net stop fhem & net start fhem');
} }
} }
exit($exitValue); exit($exitValue ? $exitValue : 0);
} }