Setting max number of open files per process?

Setting max number of open files per process?

Post by SK » Sat, 17 Aug 1996 04:00:00



Hi all!

Does anyone know the C language UNIX system call under SUN OS 4.1.3,
to set the maximum number of open files per process?

It seems that a default number is 61 ????

Thanks in advance!

Steinar Karlsen.

 
 
 

Setting max number of open files per process?

Post by Ken Pizzi » Sun, 18 Aug 1996 04:00:00




>Does anyone know the C language UNIX system call under SUN OS 4.1.3,
>to set the maximum number of open files per process?

I don't recall if that is a tunable parameter under that OS,
but if it is at all it involves a kernel rebuild, not a simple
system call.

Quote:>It seems that a default number is 61 ????

64.  But remember that your process starts out with stdin, stdout,
and stderr (under normal circumstances), leaving 61 if you don't
close any of these.

                --Ken Pizzini

 
 
 

Setting max number of open files per process?

Post by Rui Duarte Tavares Bast » Tue, 20 Aug 1996 04:00:00


-----BEGIN PGP SIGNED MESSAGE-----



>Hi all!

>Does anyone know the C language UNIX system call under SUN OS 4.1.3,
>to set the maximum number of open files per process?

>It seems that a default number is 61 ????

  Probably the limit is 64 ... the 61 + 0 (stdin) + 1 (stdout)
and 2 (stderr).

  To change that you must recompile the kernel. There's no such
system call to do that.

Hope this helps,
- --


********** http://jupiter.di.uminho.pt/~rui ***************

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3i
Charset: noconv

iQCVAwUBMhjYNFCBIPblTRelAQHQSQP/dBoe+GP1Qifg+41TUHKsgrCMwe99MwWT
p5hS0OHAOKyvNRTxrGwYl37Tal8zCsZZOsz0r/EzEjTAlNgKXTiBZ9ho+4aJICxv
JaMCn8XLXV/48aGhn7ZWgJcR2syAjZBO3U+5/YgxafJpnIkkyANuHILCinJACYny
z/3jxlTqmC8=
=ox2q
-----END PGP SIGNATURE-----

 
 
 

Setting max number of open files per process?

Post by BOFH » Wed, 21 Aug 1996 04:00:00



: -----BEGIN PGP SIGNED MESSAGE-----


: >Hi all!
: >
: >Does anyone know the C language UNIX system call under SUN OS 4.1.3,
: >to set the maximum number of open files per process?
: >
: >It seems that a default number is 61 ????

:   Probably the limit is 64 ... the 61 + 0 (stdin) + 1 (stdout)
: and 2 (stderr).

:   To change that you must recompile the kernel. There's no such
: system call to do that.

No offense intended, but you need to read your man pages more often.
There most certainly is a system call for this. getrlimit() and setrlimit().

The 64 process limit is only a soft limit. To find out the hard limits,
an easy way is to invoke csh, type limit (to print out the soft limits),
unlimit (to remove the soft limits), and then limit again to print out
the new values.

Usually, I'll do something like the example below:

#include <sys/types.h>
#include <time.h>
#include <sys/resource.h>

/*
 * int setlimits(void)
 * set system resource limits
 */

int
setlimits(void)
{

struct rlimit rlp;

/* We need more than POSIX OPEN_MAX open file descriptors */

if (getrlimit(RLIMIT_NOFILE, &rlp) != 0) {
   fprintf(stderr, "Can't get limits\n");
   return -1;

Quote:}

/* set the current value as high as allowed */
rlp.rlim_cur = rlp.rlim_max;

if (setrlimit(RLIMIT_NOFILE, &rlp) != 0) {
   fprintf(stderr, "Can't set limits\n");
   return -1;

Quote:}

/* All okay */
return 0;
Quote:}

 
 
 

Setting max number of open files per process?

Post by Guy Harr » Thu, 22 Aug 1996 04:00:00



>Does anyone know the C language UNIX system call under SUN OS 4.1.3,
>to set the maximum number of open files per process?

>I don't recall if that is a tunable parameter under that OS,
>but if it is at all it involves a kernel rebuild, not a simple
>system call.

It's not tunable.

*However*, it's a "setrlimit()"-controllable resource limit; the soft
limit is 64, but the hard limit is 256 (or 1024 if you have the SunDBE
product, I think), and a process can crank its soft limit up to the hard
limit.  See the GETRLIMIT(2) man page, which describes "getrlimit()" and
"setrlimit()".

(Some other UNIXes also have an RLIMIT_NOFILE resource limit, e.g.
SVR4-flavored UNIXes such as SunOS 5.x.)

Cranking the *hard* limit up would probably require you to be root and,
at least in SunOS 4.1[.x], I don't think you can crank it up even if
you're root.

 
 
 

Setting max number of open files per process?

Post by Guy Harr » Fri, 23 Aug 1996 04:00:00


 >To find out the hard limits,
 >an easy way is to invoke csh, type limit (to print out the soft limits),
 >unlimit (to remove the soft limits), and then limit again to print out
 >the new values.

An easier way to find out the hard limits is to invoke "csh" (if you're
not already running it), and then type "limit -h".

(In SVR4-flavored systems such as SunOS 5.x, you can set and print the
limits in the Bourne and Korn shells with the "ulimit" command, but the
SunOS 4.x Bourne shell doesn't let you do that.)