From 722aa042b7a270d8da3f2a7c78c77dd59d67eb9b Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Sun, 17 Jul 2022 00:49:26 +0000 Subject: [PATCH] main: Increase FD limit This defaults to 1024, which is tiny, but is a requirement for processes using the deprecated `select` function. We must reset this back whenever we fork to start a new process, as this is inherited, and breaks applications using `select` otherwise. Signed-off-by: Joshua Ashton --- src/common/spawn.c | 3 +++ src/main.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/common/spawn.c b/src/common/spawn.c index d8d0abd4..349f65fc 100644 --- a/src/common/spawn.c +++ b/src/common/spawn.c @@ -10,6 +10,7 @@ #include #include #include "common/spawn.h" +#include "common/fd_util.h" void spawn_async_no_shell(char const *command) @@ -39,6 +40,8 @@ spawn_async_no_shell(char const *command) wlr_log(WLR_ERROR, "unable to fork()"); goto out; case 0: + restore_nofile_limit(); + setsid(); sigset_t set; sigemptyset(&set); diff --git a/src/main.c b/src/main.c index 1e2dc1ee..0cb521b5 100644 --- a/src/main.c +++ b/src/main.c @@ -9,6 +9,7 @@ #include "theme.h" #include "xbm/xbm.h" #include "menu/menu.h" +#include "common/fd_util.h" struct rcxml rc = { 0 }; @@ -85,6 +86,8 @@ main(int argc, char *argv[]) exit(EXIT_FAILURE); } + increase_nofile_limit(); + struct server server = { 0 }; server_init(&server); server_start(&server);