]> arthur.barton.de Git - netdata.git/blobdiff - src/main.c
Update debian/changelog
[netdata.git] / src / main.c
index ade14e4a6b37096ee5ccc739de48696c298e58cc..8dcc5d7097142b7fe501b5391749bf18ee2176b4 100644 (file)
@@ -332,8 +332,7 @@ static const char *verify_required_directory(const char *dir) {
     return dir;
 }
 
-int main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
     char *hostname = "localhost";
     int i, check_config = 0;
     int config_loaded = 0;
@@ -507,6 +506,16 @@ int main(int argc, char **argv)
         }
     }
 
+#ifdef _SC_OPEN_MAX
+    // close all open file descriptors, except the standard ones
+    // the caller may have left open files (lxc-attach has this issue)
+    {
+        int fd;
+        for(fd = (int) (sysconf(_SC_OPEN_MAX) - 1); fd > 2; fd--)
+            if(fd_is_valid(fd)) close(fd);
+    }
+#endif
+
     if(!config_loaded)
         load_config(NULL, 0);