diff options
author | Leah Neukirchen <leah@vuxu.org> | 2024-02-07 14:35:02 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2024-02-07 14:54:55 +0100 |
commit | a23c3252420fc9473c5e9a1f2bd6bb16d5494e43 (patch) | |
tree | 56d06ab20915199fd48258a7e797ee8888f95894 | |
parent | 17db992bc5493cc1e7175a7d7c2dd4ca031b00cf (diff) | |
download | nitro-a23c3252420fc9473c5e9a1f2bd6bb16d5494e43.tar.gz nitro-a23c3252420fc9473c5e9a1f2bd6bb16d5494e43.tar.xz nitro-a23c3252420fc9473c5e9a1f2bd6bb16d5494e43.zip |
be more robust when running out of file descriptors
-rw-r--r-- | nitro.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/nitro.c b/nitro.c index 31e4186..1f99560 100644 --- a/nitro.c +++ b/nitro.c @@ -305,8 +305,14 @@ proc_launch(int i) unsigned char status; int alivepipefd[2]; - if (pipe(alivepipefd) < 0) - abort(); + if (pipe(alivepipefd) < 0) { + /* pipe failed, delay */ + prn(2, "- nitro: can't create status pipe: errno=%d\n", errno); + services[i].state = PROC_DELAY; + services[i].timeout = 2000; + services[i].deadline = 0; + return; + } fcntl(alivepipefd[0], F_SETFD, FD_CLOEXEC); fcntl(alivepipefd[1], F_SETFD, FD_CLOEXEC); @@ -880,11 +886,16 @@ rescan(int first) int j = add_service(buf); services[j].islog = 1; if (services[j].logpipe[0] == -1) { - pipe(services[i].logpipe); - fcntl(services[i].logpipe[0], F_SETFD, FD_CLOEXEC); - fcntl(services[i].logpipe[1], F_SETFD, FD_CLOEXEC); - services[j].logpipe[0] = services[i].logpipe[0]; - services[j].logpipe[1] = services[i].logpipe[1]; + if (pipe(services[i].logpipe) < 0) { + prn(2, "- nitro: can't create log pipe: errno=%d\n", errno); + services[i].logpipe[0] = -1; + services[i].logpipe[1] = -1; + } else { + fcntl(services[i].logpipe[0], F_SETFD, FD_CLOEXEC); + fcntl(services[i].logpipe[1], F_SETFD, FD_CLOEXEC); + services[j].logpipe[0] = services[i].logpipe[0]; + services[j].logpipe[1] = services[i].logpipe[1]; + } } } } |