diff options
Diffstat (limited to 'xD.c')
-rw-r--r-- | xD.c | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -1,7 +1,7 @@ /* * xD.c: an IRC daemon * - * Copyright (c) 2014 - 2020, Přemysl Eric Janouch <p@janouch.name> + * Copyright (c) 2014 - 2021, Přemysl Eric Janouch <p@janouch.name> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted. @@ -22,7 +22,9 @@ #define WANT_SYSLOG_LOGGING #include "common.c" #include "xD-replies.c" + #include <nl_types.h> +#include <sys/resource.h> enum { PIPE_READ, PIPE_WRITE }; @@ -3984,6 +3986,21 @@ daemonize (struct server_context *ctx) poller_post_fork (&ctx->poller); } +static void +setup_limits (void) +{ + struct rlimit limit; + if (getrlimit (RLIMIT_NOFILE, &limit)) + { + print_warning ("%s: %s", "getrlimit", strerror (errno)); + return; + } + + limit.rlim_cur = limit.rlim_max; + if (setrlimit (RLIMIT_NOFILE, &limit)) + print_warning ("%s: %s", "setrlimit", strerror (errno)); +} + int main (int argc, char *argv[]) { @@ -4030,6 +4047,7 @@ main (int argc, char *argv[]) print_status (PROGRAM_NAME " " PROGRAM_VERSION " starting"); setup_signal_handlers (); + setup_limits (); init_openssl (); struct server_context ctx; |