*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->HP-UX 11i man pages -> setrlimit (2)              
Title
Content
Arch
Section
 

Contents


 getrlimit(2)                                                   getrlimit(2)




 NAME    [Toc]    [Back]
      getrlimit(), setrlimit() - control maximum resource consumption

 SYNOPSIS    [Toc]    [Back]
      #include <sys/resource.h>

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

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

 DESCRIPTION    [Toc]    [Back]
      Limits on the consumption of a variety of resources by the calling
      process may be obtained with getrlimit() and set with setrlimit().
      Each call to either getrlimit() or setrlimit() identifies a specific
      resource to be operated upon as well as a resource limit.  A resource
      limit is represented by an rlimit structure, pointed to by the rlp
      argument and includes the following members:

           rlim_t rlim_cur;        /* Current (soft) limit */
           rlim_t rlim_max;        /* Hard limit */

      The rlim_cur member specifies the current or soft limit and the
      rlim_max member specifies the maximum or hard limit.  Soft limits may
      be changed by a process to any value that is less than or equal to the
      hard limit.  A process may (irreversibly) lower its hard limit to any
      value that is greater than or equal to the soft limit.  Only a process
      with appropriate privileges can raise a hard limit.  Both hard and
      soft limits can be changed in a single call to setrlimit() subject to
      the constraints described above.

      The value RLIM_INFINITY, defined in <sys/resource.h>, is considered to
      be larger than any other limit value.  If a call to getrlimit()
      returns RLIM_INFINITY for a resource, it means the implementation does
      not enforce limits on that resource.  Specifying RLIM_INFINITY as any
      resource limit value on a successful call to setrlimit() inhibits
      enforcement of that resource limit.

      The following resources are defined:

      RLIMIT_CORE              This is the maximum size of a core file in
                               bytes that may be created by a process.  A
                               limit of 0 will prevent the creation of a
                               core file.  If this limit is exceeded, the
                               writing of a core file will terminate at this
                               size.

      RLIMIT_CPU               This is the maximum amount of CPU time in
                               seconds allowed for a UNIX 95 conforming
                               application.  If this limit is exceeded,
                               SIGXCPU is generated for the application.
                               The default action for a UNIX 95 conforming



 Hewlett-Packard Company            - 1 -   HP-UX 11i Version 2: August 2003






 getrlimit(2)                                                   getrlimit(2)




                               application is to kill the process and leave
                               a core file.  If the process is blocking,
                               catching or ignoring SIGXCPU, the behavior is
                               unspecified in UNIX 95 standard.  The HP-UX
                               implementation blocks, catches or ignores
                               SIGXCPU as specified by the UNIX 95
                               conforming applications.  Be aware that an
                               application designed with the HP-UX behavior
                               may not be portable if and when UNIX
                               standards define a different behavior.  If
                               the application is a Classic HP-UX
                               application, the kernel will not send the
                               signal as a result of exceeding the CPU
                               limit.  However, if this signal is sent
                               explicitly to a Classic HP-UX application by
                               another application or via the kill -XCPU
                               command, this signal will be delivered and
                               the default action will be taken.  In order
                               for an application to be UNIX 95, it must be
                               linked with unix95.o either directly or
                               indirectly.  For example:

                                    % cc /usr/lib/unix95.o prog.c

                               Or,

                                    % export UNIX95=1
                                    % cc prog.c

      RLIMIT_DATA              This is the maximum size of a process data
                               segment in bytes.  If this limit is exceeded,
                               the brk(), malloc(), and sbrk() functions
                               will fail with errno set to ENOMEM.  Attempts
                               to set RLIMIT_DATA to RLIM_INFINITY will
                               always fail.  The upper limit is enforced
                               through the tunable maxdsiz.

      RLIMIT_FSIZE             This option is only applicable to UNIX 95
                               conforming applications.  Please see
                               RLIMIT_CPU option above for explanation on
                               UNIX 95 conforming applications.  This is the
                               maximum size of a file in bytes that may be
                               created by a process.  A limit of 0 will
                               prevent the creation of a file.  If a write
                               or truncate operation would cause this limit
                               to be exceeded, SIGXFSZ is generated for the
                               process.  If the process is blocking,
                               catching or ignoring SIGXFSZ, continued
                               attempts to increase the size of a file from
                               end-of-file to beyond the limit will fail
                               with errno set to [EFBIG].



 Hewlett-Packard Company            - 2 -   HP-UX 11i Version 2: August 2003






 getrlimit(2)                                                   getrlimit(2)




      RLIMIT_NOFILE            This is a number one greater than the maximum
                               value that the system may assign to a newlycreated
 descriptor.  If this limit is
                               exceeded, functions that allocate new file
                               descriptors may fail with errno set to
                               [EMFILE].  This limit constrains the number
                               of file descriptors that a process may
                               allocate.

      RLIMIT_STACK             This is the maximum size of a process stack
                               in bytes.  The implementation will not
                               automatically grow the stack beyond this
                               limit.  If this limit is exceeded, SIGSEGV is
                               generated for the process.  If the process is
                               blocking or ignoring SIGSEGV, or is catching
                               SIGSEGV and has not made arrangements to use
                               an alternate stack, the disposition of
                               SIGSEGV will be set to SIG_DFL before it is
                               generated.  Attempts to set RLIMIT_STACK to
                               RLIM_INFINITY will always fail.  The upper
                               limit is enforced through the tunable
                               maxssiz.

      RLIMIT_AS                This is the maximum size of a process's total
                               available memory, in bytes.  If this limit is
                               exceeded, the brk(), malloc(), mmap(), and
                               sbrk() functions will fail with errno set to
                               [ENOMEM].  In addition, the automatic stack
                               growth will fail with the effects outlined
                               above.

      RLIMIT_AIO_OPS           This is the maximum number of POSIX
                               Asynchronous I/O operations that a process
                               can have enqueued simultaneously.  If this
                               limit is exceeded, the aio_read(),
                               aio_write(), and lio_listio() functions will
                               fail with errno set to [EAGAIN].

      RLIMIT_AIO_MEM           This is the maximum number of bytes of memory
                               that can be locked simultaneously by POSIX
                               Asynchronous I/O requests from a single
                               process.

 RETURN VALUE    [Toc]    [Back]
      Upon successful completion, getrlimit() and setrlimit() return 0.
      Otherwise, these functions return -1 and set errno to indicate the
      error.

 ERRORS    [Toc]    [Back]
      The getrlimit() and setrlimit() functions will fail if:




 Hewlett-Packard Company            - 3 -   HP-UX 11i Version 2: August 2003






 getrlimit(2)                                                   getrlimit(2)




           [EINVAL]       An invalid resource was specified; or in a
                          setrlimit() call, the new rlim_cur exceeds the new
                          rlim_max.

           [EFAULT]       The address specified for rlp is invalid.
                          Reliable detection of this error is implementation
                          dependent.

           [EPERM]        The limit specified to setrlimit() would have
                          raised the maximum limit value, and the calling
                          process does not have appropriate privileges.

      The setrlimit() function may fail if:

           [EINVAL]       The limit specified cannot be lowered because
                          current usage is already higher than the limit.

           [EPERM]        The rlp argument specified a hard or soft limit
                          higher than the current hard limit value, and the
                          caller does not have the appropriate privileges.

           [EINVAL]       A user with appropriate privileges has attempted
                          to raise rlp->rlim_cur or rlp->rlim_max to a value
                          greater than the system is capable of supporting.

           [EINVAL]       The value of rlp->rlim_cur is less than the number
                          of file descriptors the process already has
                          allocated.

           [EINVAL]       The value of rlp->rlim_max is less than the
                          current soft limit.

 WARNINGS    [Toc]    [Back]
      The maximum size of a file returned by getrlimit() is in terms of
      bytes.  The maximum size of a file returned by ulimit (see ulimit(2))
      with UL_GETFSIZE is in terms of blocks of size 512 bytes.  The value
      returned by ulimit with UL_GETFSIZE may thus have to be rounded down
      to a multiple of 512.

      The total address space used by a process depends on the platform it
      is run on.  When porting applications, limits set by setrlimit() with
      RLIMIT_AS may need to be adjusted.  For example, programs tend to use
      more memory on Itanium-based systems than on PA-RISC systems.

 AUTHOR    [Toc]    [Back]
      getrlimit() and setrlimit() were developed by HP, AT&T, and the
      University of California, Berkeley.

 SEE ALSO    [Toc]    [Back]
      brk(2), exec(2), fork(2), creat64(2), malloc(3C), open(2),
      sigaltstack(2), sysconf(2), ulimit(2), maxdsiz(5), maxssiz(5),



 Hewlett-Packard Company            - 4 -   HP-UX 11i Version 2: August 2003






 getrlimit(2)                                                   getrlimit(2)




      <stropts.h>, <sys/resource.h>.

 CHANGE HISTORY    [Toc]    [Back]
      First released in Issue 4, Version 2.


 Hewlett-Packard Company            - 5 -   HP-UX 11i Version 2: August 2003
[ Back ]
      
      
 Similar pages
Name OS Title
getrlimit IRIX control maximum system resource consumption
setrlimit OpenBSD control maximum system resource consumption
setrlimit NetBSD control maximum system resource consumption
getrlimit NetBSD control maximum system resource consumption
getrlimit Tru64 Control maximum system resource consumption
setrlimit FreeBSD control maximum system resource consumption
setrlimit Tru64 Control maximum system resource consumption
getrlimit FreeBSD control maximum system resource consumption
getrlimit OpenBSD control maximum system resource consumption
cvmeter IRIX examine process resource consumption data
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service