7 /* set/get open file limit
9 /* #include <iostuff.h>
11 /* int open_limit(int limit)
13 /* The \fIopen_limit\fR() routine attempts to change the maximum
14 /* number of open files to the specified limit. Specify a null
15 /* argument to effect no change. The result is the actual open file
16 /* limit for the current process. The number can be smaller or larger
17 /* than the requested limit.
19 /* open_limit() returns -1 in case of problems. The errno
20 /* variable gives hints about the nature of the problem.
24 /* The Secure Mailer license must be distributed with this software.
27 /* IBM T.J. Watson Research
29 /* Yorktown Heights, NY 10598, USA
32 /* System libraries. */
36 #include <sys/resource.h>
39 /* Application-specific. */
44 * 44BSD compatibility.
48 #define RLIMIT_NOFILE RLIMIT_OFILE
52 /* open_limit - set/query file descriptor limit */
54 int open_limit(int limit
)
65 if (getrlimit(RLIMIT_NOFILE
, &rl
) < 0)
68 if (limit
> rl
.rlim_max
)
69 rl
.rlim_cur
= rl
.rlim_max
;
72 if (setrlimit(RLIMIT_NOFILE
, &rl
) < 0)
79 return (getdtablesize());