From: Stefan Schantl Date: Sat, 18 Oct 2014 15:59:03 +0000 (+0200) Subject: guardian: Exit if no files are watched. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e419e5154c6be00857f54693c47ecb6c7a098aad;p=people%2Fstevee%2Fipfire-2.x.git guardian: Exit if no files are watched. --- diff --git a/config/guardian/guardian.pl b/config/guardian/guardian.pl index 9bb586f5a6..99723c88fa 100644 --- a/config/guardian/guardian.pl +++ b/config/guardian/guardian.pl @@ -291,10 +291,18 @@ sub handle_httpd ($) { sub create_watcher { $watcher = new Linux::Inotify2 or die "Could not use inotify. $!\n"; + # Check if the array contains elements. + if(@monitored_files) { # Create watcher for each file in array. - foreach my $file (@monitored_files) { - $watcher->watch("$file", IN_MODIFY) or die "Could not monitor $file. $!\n"; - &logger("debug", "Created watcher for $file\n"); + foreach my $file (@monitored_files) { + $watcher->watch("$file", IN_MODIFY) or die "Could not monitor $file. $!\n"; + &logger("debug", "Created watcher for $file\n"); + } + } else { + &logger("info", "No file(s) to watch. Exiting.\n"); + + # Call subroutine to safe exit the programm. + &clean_up_and_exit; } }