aboutgitcodebugslistschat
path: root/passt.c
diff options
context:
space:
mode:
Diffstat (limited to 'passt.c')
-rw-r--r--passt.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/passt.c b/passt.c
index 9786221..6b160c0 100644
--- a/passt.c
+++ b/passt.c
@@ -18,6 +18,7 @@
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/ioctl.h>
+#include <sys/resource.h>
#include <sys/un.h>
#include <ifaddrs.h>
#include <linux/if_ether.h>
@@ -513,6 +514,7 @@ int main(int argc, char **argv)
struct timespec last_time;
struct ctx c = { 0 };
int nfds, i, fd_unix;
+ struct rlimit limit;
if (argc != 1)
usage(argv[0]);
@@ -528,6 +530,16 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
+ if (getrlimit(RLIMIT_NOFILE, &limit)) {
+ perror("getrlimit");
+ exit(EXIT_FAILURE);
+ }
+ limit.rlim_cur = limit.rlim_max;
+ if (setrlimit(RLIMIT_NOFILE, &limit)) {
+ perror("setrlimit");
+ exit(EXIT_FAILURE);
+ }
+
if (icmp_sock_init(&c) || tcp_sock_init(&c) || udp_sock_init(&c))
exit(EXIT_FAILURE);