@cryptotaxi247 / netdata-1 / commits / e099b5abf

fix lxc-attach not exiting after starting netdata

Costa Tsaousis (ktsaou) committed Feb 12, 2017 at 17:41 UTC e099b5abf7534d92367e9751bcd7630dba8f086a
1 file changed +11 -2
src/main.c
+11 -2
@@ -332,8 +332,7 @@ static const char *verify_required_directory(const char *dir) {
332 return dir;
333 }
334
335 -int main(int argc, char **argv)
336 -{
335 +int main(int argc, char **argv) {
336 char *hostname = "localhost";
337 int i, check_config = 0;
338 int config_loaded = 0;
@@ -507,6 +506,16 @@ int main(int argc, char **argv)
506 }
507 }
508
509 +#ifdef _SC_OPEN_MAX
510 + // close all open file descriptors, except the standard ones
511 + // the caller may have left open files (lxc-attach has this issue)
512 + {
513 + int fd;
514 + for(fd = (int) (sysconf(_SC_OPEN_MAX) - 1); fd > 2; fd--)
515 + if(fd_is_valid(fd)) close(fd);
516 + }
517 +#endif
518 +
519 if(!config_loaded)
520 load_config(NULL, 0);
521