]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Added restrict_get_fd_limit()
authorTimo Sirainen <tss@iki.fi>
Wed, 23 Nov 2011 17:51:01 +0000 (19:51 +0200)
committerTimo Sirainen <tss@iki.fi>
Wed, 23 Nov 2011 17:51:01 +0000 (19:51 +0200)
src/lib/restrict-process-size.c
src/lib/restrict-process-size.h

index 7a7178b966ba6925f8958cd5ec3025a7444f81b5..ec226be89af6dafa123c988205482633d8206dcf 100644 (file)
@@ -80,3 +80,15 @@ int restrict_get_process_limit(rlim_t *limit_r)
        return -1;
 #endif
 }
+
+int restrict_get_fd_limit(rlim_t *limit_r)
+{
+       struct rlimit rlim;
+
+       if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) {
+               i_error("getrlimit(RLIMIT_NOFILE) failed: %m");
+               return -1;
+       }
+       *limit_r = rlim.rlim_cur;
+       return 0;
+}
index d4d71b0e0391284fd712cb6bd3206e83928d8b33..955e4aa5af5926199b4eb9be6efddb1fe83d2682 100644 (file)
@@ -17,5 +17,7 @@ void restrict_fd_limit(rlim_t count);
 int restrict_get_core_limit(rlim_t *limit_r);
 /* Get the process count limit. Returns 0 if ok, -1 if lookup failed. */
 int restrict_get_process_limit(rlim_t *limit_r);
+/* Get the fd limit. Returns 0 if ok, -1 if lookup failed. */
+int restrict_get_fd_limit(rlim_t *limit_r);
 
 #endif