diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2012-06-09 03:12:55 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2012-06-09 03:12:55 +0200 |
commit | aadd733dc2f9540439239f1cf9b267c1947e4ddb (patch) | |
tree | d167845ed9bf1084d9c21197aff20522e5e6b4d0 | |
parent | Increase rlimits. (diff) | |
download | mulder-listen-daemon-aadd733dc2f9540439239f1cf9b267c1947e4ddb.tar.xz mulder-listen-daemon-aadd733dc2f9540439239f1cf9b267c1947e4ddb.zip |
Fix up rlimit crash and close crash.
-rw-r--r-- | mulderd.c | 14 |
1 files changed, 5 insertions, 9 deletions
@@ -27,7 +27,6 @@ #include <sys/resource.h> #include <netinet/in.h> - static char truth[] = "\033[32;1m\n\n" " _,--=--._\n" " ,' _ `.\n" @@ -75,11 +74,6 @@ void drop_privileges() exit(EXIT_FAILURE); } } - limit.rlim_cur = limit.rlim_max = 8192; - setrlimit(RLIMIT_DATA, &limit); - setrlimit(RLIMIT_MEMLOCK, &limit); - setrlimit(RLIMIT_AS, &limit); - setrlimit(RLIMIT_STACK, &limit); limit.rlim_cur = limit.rlim_max = 0; setrlimit(RLIMIT_CORE, &limit); setrlimit(RLIMIT_NPROC, &limit); @@ -197,10 +191,14 @@ int main(int argc, char *argv[]) } } if (daemonize) { - if (daemon(0, connection_log != 0) < 0) { + if (daemon(0, 1) < 0) { perror("daemon"); return EXIT_FAILURE; } + if (!connection_file) { + close(STDERR_FILENO); + close(STDOUT_FILENO); + } } if (pid_file) { if (fprintf(pidfile, "%d\n", getpid()) < 0) { @@ -211,9 +209,7 @@ int main(int argc, char *argv[]) } drop_privileges(); - prctl(PR_SET_NAME, "truth beacon"); - timeout.tv_sec = 1; timeout.tv_usec = 0; |