1ULIMIT(3P)                 POSIX Programmer's Manual                ULIMIT(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       ulimit — get and set process limits
13

SYNOPSIS

15       #include <ulimit.h>
16
17       long ulimit(int cmd, ...);
18

DESCRIPTION

20       The ulimit() function shall control process limits. The process  limits
21       that  can  be controlled by this function include the maximum size of a
22       single file that can be written (this  is  equivalent  to  using  setr‐
23       limit()  with  RLIMIT_FSIZE).  The  cmd  values, defined in <ulimit.h>,
24       include:
25
26       UL_GETFSIZE Return the file size limit (RLIMIT_FSIZE) of  the  process.
27                   The limit shall be in units of 512-byte blocks and shall be
28                   inherited by child processes. Files  of  any  size  can  be
29                   read.  The  return  value  shall be the integer part of the
30                   soft file size limit divided by 512. If the  result  cannot
31                   be represented as a long, the result is unspecified.
32
33       UL_SETFSIZE Set  the  file  size  limit  for  output  operations of the
34                   process to the value of the second  argument,  taken  as  a
35                   long,  multiplied  by  512. If the result would overflow an
36                   rlim_t, the actual value set is  unspecified.  Any  process
37                   may  decrease its own limit, but only a process with appro‐
38                   priate privileges may increase the limit. The return  value
39                   shall  be  the  integer  part  of  the  new file size limit
40                   divided by 512.
41
42       The ulimit() function shall not change the setting of errno if success‐
43       ful.
44
45       As  all  return  values  are  permissible in a successful situation, an
46       application wishing to check for error situations should set  errno  to
47       0,  then call ulimit(), and, if it returns -1, check to see if errno is
48       non-zero.
49

RETURN VALUE

51       Upon successful completion, ulimit() shall  return  the  value  of  the
52       requested limit. Otherwise, -1 shall be returned and errno set to indi‐
53       cate the error.
54

ERRORS

56       The ulimit() function shall fail and the limit shall be unchanged if:
57
58       EINVAL The cmd argument is not valid.
59
60       EPERM  A process not having appropriate privileges attempts to increase
61              its file size limit.
62
63       The following sections are informative.
64

EXAMPLES

66       None.
67

APPLICATION USAGE

69       Since  the  ulimit()  function  uses type long rather than rlim_t, this
70       function is not sufficient for file  sizes  on  many  current  systems.
71       Applications  should  use  the  getrlimit()  or  setrlimit()  functions
72       instead of the obsolescent ulimit() function.
73

RATIONALE

75       None.
76