" +----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+--->\n"
"\n"
" Copyright (C) 2016-2017, Costa Tsaousis <costa@tsaousis.gr>\n"
- " Released under GNU Public License v3 or later.\n"
+ " Released under GNU General Public License v3 or later.\n"
" All rights reserved.\n"
"\n"
" Home Page : https://my-netdata.io\n"
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;
int dont_fork = 0;
- int oom_score = 1000;
size_t wanted_stacksize = 0, stacksize = 0;
pthread_attr_t attr;
config_set("global", "run as user", optarg);
break;
case 'v':
- // TODO: Outsource version to makefile which can compute version from git.
- printf("netdata %s\n", VERSION);
+ printf("%s %s\n", program_name, program_version);
return 0;
case 'W':
{
}
}
+#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);
if(setrlimit(RLIMIT_CORE, &rl) != 0)
error("Cannot request unlimited core dumps for debugging... Proceeding anyway...");
-#if !(defined(__FreeBSD__) || defined(__APPLE__))
+#ifdef HAVE_SYS_PRCTL_H
prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
-#endif /* __FreeBSD__ || __APPLE__*/
+#endif
}
// --------------------------------------------------------------------
// --------------------------------------------------------------------
rrd_memory_mode = rrd_memory_mode_id(config_get("global", "memory mode", rrd_memory_mode_name(rrd_memory_mode)));
- oom_score = (int)config_get_number("global", "OOM score", oom_score);
// --------------------------------------------------------------------
struct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY };
if(setrlimit(RLIMIT_CORE, &rl) != 0)
error("Cannot request unlimited core dumps for debugging... Proceeding anyway...");
-#if !(defined(__FreeBSD__) || defined(__APPLE__))
+#ifdef HAVE_SYS_PRCTL_H
prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
-#endif /* __FreeBSD__ || __APPLE__*/
+#endif
}
#endif /* NETDATA_INTERNAL_CHECKS */
// fork, switch user, create pid file, set process priority
- if(become_daemon(dont_fork, user, oom_score) == -1)
+ if(become_daemon(dont_fork, user) == -1)
fatal("Cannot daemonize myself.");
info("netdata started on pid %d.", getpid());