]> git.ipfire.org Git - people/stevee/ipfire-2.x.git/commitdiff
guardian: Exit if no files are watched.
authorStefan Schantl <stefan.schantl@ipfire.org>
Sat, 18 Oct 2014 15:59:03 +0000 (17:59 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Sat, 18 Oct 2014 15:59:03 +0000 (17:59 +0200)
config/guardian/guardian.pl

index 9bb586f5a6ed837e28ae3f3d44822bc852fc39ea..99723c88fa95ca6c6c0c35943c053222f3f75540 100644 (file)
@@ -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;
        }
 }