Skip to content

Commit

Permalink
master: Set our own rlimit for number of fds
Browse files Browse the repository at this point in the history
We should never open more than 1024 file descriptors anyway, and under some
situations, namely running as root or in docker, would give us huge
allowances. This then results in a huge, unneeded, cleanup for subprocesses,
which we use a lot.

Fixes #2977
  • Loading branch information
cdecker authored and rustyrussell committed Sep 25, 2019
1 parent 6999a4c commit 07e6f43
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lightningd/lightningd.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
#include <lightningd/options.h>
#include <onchaind/onchain_wire.h>
#include <signal.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
Expand Down Expand Up @@ -630,6 +631,11 @@ int main(int argc, char *argv[])
struct timers *timers;
const char *stop_response;
struct htlc_in_map *unprocessed_htlcs;
struct rlimit nofile = {1024, 1024};

/*~ Make sure that we limit ourselves to something reasonable. Modesty
* is a virtue. */
setrlimit(RLIMIT_NOFILE, &nofile);

/*~ What happens in strange locales should stay there. */
setup_locale();
Expand Down

0 comments on commit 07e6f43

Please sign in to comment.