


      GETRLIMIT(2)                (bsd 4.2)                GETRLIMIT(2)



      NAME
           getrlimit, setrlimit - control maximum system resource
           consumption

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

           getrlimit(resource, rlp)
           int resource;
           struct rlimit *rlp;

           setrlimit(resource, rlp)
           int resource;
           struct rlimit *rlp;

      DESCRIPTION
           Limits on the consumption of system resources by the current
           process and each process it creates may be obtained with the
           getrlimit call, and set with the setrlimit call.

           The resource parameter is one of the following:

           RLIMIT_DATA      the maximum size, in bytes, of the data
                            segment for a process; this defines how far
                            a program may extend its break.

           RLIMIT_STACK     the maximum size, in bytes, of the stack
                            segment for a process; this defines how far
                            a program's stack segment may be extended.

           A resource limit is specified as a soft limit and a hard
           limit.  When a soft limit is exceeded a process may receive
           a signal, but it will be allowed to continue execution until
           it reaches the hard limit (or modifies its resource limit).

           The standard action when a resource limit is exceeded is one
           of the following:

           RLIMIT_DATA      when the soft limit is exceeded a SIGSEGV
                            signal is generated.  If the hard limit has
                            not been exceeded, the soft limit is first
                            increased to include the offending offset.
                            If the process is ignoring SIGSEGV signals,
                            execution simply continues with the new
                            soft limit.

           RLIMIT_STACK     when the soft limit is exceeded a SIGSEGV
                            signal is generated.  If the hard limit has
                            not been exceeded, the soft limit is first
                            increased to include the offending offset.
                            If the process is ignoring SIGSEGV signals,



      Page 1                                         (73 A2 02MTA REV1)






      GETRLIMIT(2)                (bsd 4.2)                GETRLIMIT(2)



                            execution simply continues with the new
                            soft limit.

           The rlimit structure is used to specify the hard and soft
           limits on a resource,

                struct rlimit {
                     int  rlim_cur; /* current (soft) limit */
                     int  rlim_max; /* hard limit */
                };

           Only the super-user may raise the maximum limits.  Other
           users may only alter rlim_cur within the range from 0 to
           rlim_max or (irreversibly) lower rlim_max.

           An infinite value for a limit is defined as RLIMIT_INFINITY
           (0x7fffffff).

           Because this information is stored in the per-process
           information, this system call must be executed directly by
           the shell if it is to affect all future processes created by
           the shell; limit is thus a built-in command to csh(1).

           The system refuses to extend the data or stack space when
           the limits would be exceeded in the normal way: a break call
           fails if the data space limit is reached, or the process is
           killed when the stack limit is reached (since the stack
           cannot be extended, there is no way to send a signal!).

      RETURN VALUE
           A 0 return value indicates that the call succeeded, changing
           or returning the resource limit.   A return value of -1
           indicates that an error occurred, and an error code is
           stored in the global location errno.

      ERRORS
           The possible errors are:

           [EFAULT]       The address specified for rlp is invalid.

           [EPERM]   The limit specified to setrlimit would have
                          raised the maximum limit value, and the
                          caller is not the super-user.

      SEE ALSO
           csh(1)

      BUGS
           There should be limit and unlimit commands in sh(1) as well
           as in csh.





      Page 2                                         (73 A2 02MTA REV1)



