Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ setrlimit(2) — DG/UX R4.11

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

open(2)

sbrk(2)

sigaltstack(2)

ulimit(2)

malloc(3C)

signal(5)



getrlimit(2)                      SDK R4.11                     getrlimit(2)


NAME
       getrlimit, setrlimit - control maximum system resource consumption

SYNOPSIS
       #include <sys/time.h>
       #include <sys/resource.h>
       int getrlimit(int resource, struct rlimit *rlp);
       int setrlimit(int resource, const struct rlimit *rlp);

   where:
       resource  The resource for which the limits are to be returned or
                 set.

       rlp       A pointer to a structure into which the limit values are to
                 be placed or read from

DESCRIPTION
       Limits on the consumption of a variety of system resources by a
       process and each process it creates 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 a pair of values:  one specifying the current (soft) limit,
       the other a maximum (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 privilege can raise a hard limit.  For systems supporting
       the DG/UX Capability Option, appropriate privilege is defined as
       having one or more specific capabilities enabled in the effective
       capability set of the calling process.  See capdefaults(5) for the
       default capability for this system call.

       On systems without the DG/UX Capability Option, appropriate privilege
       means that the process has an effective UID of root.  See the
       appropriateprivilege(5) man page for more information.

       Both hard and soft limits can be changed in a single call to
       setrlimit subject to the constraints described above.  Limits may
       have an "infinite" value of RLIMINFINITY.  rlp is a pointer to
       struct rlimit that includes the following members:
            rlimt rlimcur; /* current (soft) limit */
            rlimt rlimmax; /* hard limit */

       rlimt is an arithmetic data type to which objects of type int,
       sizet, and offt can be cast without loss of information.

       The possible resources, their descriptions, and the actions taken
       when current limit is exceeded, are summarized in the table below:
         Resources       Description                 Action
       ---------------------------------------------------------------
       RLIMITCORE   The maximum size of    The writing of a core
                     a core file in bytes   file will terminate at
                     that may be created    this size.
                     by a process.  A
                     limit of 0 will
                     prevent the creation
                     of a core file.
       RLIMITCPU    The maximum amount     SIGXCPU is sent to the
                     of CPU time in         process.  If the process
                     seconds used by a      is holding or ignoring
                     process.               SIGXCPU, the behavior is
                                            scheduling class defined.
       RLIMITDATA   The maximum size of    brk(2) will fail with
                     a process's heap in    errno set to ENOMEM.
                     bytes.

         Resources       Description                 Action
       ---------------------------------------------------------------
       RLIMITFSIZE  The maximum size of    SIGXFSZ is sent to the
                     a file in bytes that   process.  If the process
                     may be created by a    is holding or ignoring
                     process.  A limit of   SIGXFSZ, continued
                     0 will prevent the     attempts to increase the
                     creation of a file.    size of a file beyond the
                                            limit will fail with
                                            errno set to EFBIG.
       RLIMITNOFILE The maximum number     Functions that create new
                     of open file           file descriptors will
                     descriptors that the   fail with errno set to
                     process can have.      EMFILE.  Or, when
                                            attempting an fcntl()
                                            "FDUPFD", return EINVAL.
       RLIMITSTACK  The maximum size of    SIGSEGV is sent to the
                     a process's stack in   process.  If the process
                     bytes.  The system     is holding or ignoring
                     will not               SIGSEGV, or is catching
                     automatically grow     SIGSEGV and has not made
                     the stack beyond       arrangements to use an
                     this limit.            alternate stack [see
                                            sigaltstack(2)], the
                                            disposition of SIGSEGV
                                            will be set to SIGDFL
                                            before it is sent.
       RLIMITAS     The maximum size of    brk(2) and mmap(2)
                     a process's mapped     functions will fail with
                     address space in       errno set to ENOMEM.
                     bytes.  This same      Also, attempting an
                     resource may be        exec(2) on an image
                     accessed by setting    greater than this limit
                     resource to            will fail, setting errno
                     RLIMITVMEM.           to ENOMEM.
       RLIMITRSS    The maximum size in    The kernel limits a
                     bytes to which a       process' resident set
                     process' resident      size to RLIMITRSS bytes.
                     set size can grow.

       Because limit information is stored in the per-process information,
       the shell builtin ulimit must directly execute this system call if it
       is to affect all future processes created by the shell.

       The value of the current limit of the following resources affect
       these implementation defined constants:
                  Limit           Implementation Defined Constant
                  ------------------------------------------------
                  RLIMITFSIZE    FCHRMAX
                  RLIMITNOFILE   OPENMAX

RETURN VALUE
       Upon successful completion, the function getrlimit returns a value of
       0; otherwise, it returns a value of -1 and sets errno to indicate an
       error.

DIAGNOSTICS
       Under the following conditions, the functions getrlimit and setrlimit
       fail and set errno to:

        EINVAL if an invalid resource was specified; or in a setrlimit call,
               the new rlimcur exceeds the new rlimmax.

        EPERM  if the limit specified to setrlimit would have raised the
               maximum limit value, and the calling process does not have
               appropriate privilege

SEE ALSO
       open(2), sbrk(2), sigaltstack(2), ulimit(2), malloc(3C),
       appropriateprivilege(5), signal(5).
       capdefaults(5).


Licensed material--property of copyright holder(s)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026