From 8949425c26ff74b4c15067fed4b2f4376d8f9482 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Tue, 9 Jul 2019 09:44:07 +0000 Subject: [PATCH] fhem.pl: Fix shutdown exitvalue for delayedshutdown (Forum #102128) git-svn-id: https://svn.fhem.de/fhem/trunk@19805 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/fhem.pl | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/fhem/fhem.pl b/fhem/fhem.pl index 9455733be..edcb4e95f 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -183,7 +183,7 @@ sub CommandSet($$); sub CommandSetReading($$); sub CommandSetstate($$); sub CommandSetuuid($$); -sub CommandShutdown($$;$$); +sub CommandShutdown($$;$$$); sub CommandSleep($$); sub CommandTrigger($$); @@ -1754,9 +1754,9 @@ CancelDelayedShutdown($) } sub -DelayedShutdown($$) +DelayedShutdown($$$) { - my ($cl, $param) = @_; + my ($cl, $param, $exitValue) = @_; return 1 if(keys %delayedShutdowns); foreach my $d (sort keys %defs) { @@ -1774,7 +1774,7 @@ DelayedShutdown($$) $checkList = sub() { - return CommandShutdown($cl, $param, undef, 1) + return CommandShutdown($cl, $param, undef, 1, $exitValue) if(!keys %delayedShutdowns || $waitingFor++ >= $maxShutdownDelay); InternalTimer(gettimeofday()+1, $checkList, undef, 0); }; @@ -1783,17 +1783,16 @@ DelayedShutdown($$) } sub -CommandShutdown($$;$$) +CommandShutdown($$;$$$) { - my ($cl, $param, $cmdName, $final) = @_; - my $exitValue = 0; + my ($cl, $param, $cmdName, $final, $exitValue) = @_; if($param && $param =~ m/^(\d+)$/) { $exitValue = $1; $param = ""; } return "Usage: shutdown [restart|exitvalue]" if($param && $param ne "restart"); - return if(!$final && DelayedShutdown($cl, $param)); + return if(!$final && DelayedShutdown($cl, $param, $exitValue)); DoTrigger("global", "SHUTDOWN", 1); Log 0, "Server shutdown"; @@ -1813,7 +1812,7 @@ CommandShutdown($$;$$) exec('cmd.exe /C net stop fhem & net start fhem'); } } - exit($exitValue); + exit($exitValue ? $exitValue : 0); }