1ULIMIT(3P) POSIX Programmer's Manual ULIMIT(3P)
2
3
4
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
11
13 ulimit — get and set process limits
14
16 #include <ulimit.h>
17
18 long ulimit(int cmd, ...);
19
21 The ulimit() function shall control process limits. The process limits
22 that can be controlled by this function include the maximum size of a
23 single file that can be written (this is equivalent to using setr‐
24 limit() with RLIMIT_FSIZE). The cmd values, defined in <ulimit.h>,
25 include:
26
27 UL_GETFSIZE Return the file size limit (RLIMIT_FSIZE) of the process.
28 The limit shall be in units of 512-byte blocks and shall be
29 inherited by child processes. Files of any size can be
30 read. The return value shall be the integer part of the
31 soft file size limit divided by 512. If the result cannot
32 be represented as a long, the result is unspecified.
33
34 UL_SETFSIZE Set the file size limit for output operations of the
35 process to the value of the second argument, taken as a
36 long, multiplied by 512. If the result would overflow an
37 rlim_t, the actual value set is unspecified. Any process
38 may decrease its own limit, but only a process with appro‐
39 priate privileges may increase the limit. The return value
40 shall be the integer part of the new file size limit
41 divided by 512.
42
43 The ulimit() function shall not change the setting of errno if success‐
44 ful.
45
46 As all return values are permissible in a successful situation, an
47 application wishing to check for error situations should set errno to
48 0, then call ulimit(), and, if it returns −1, check to see if errno is
49 non-zero.
50
52 Upon successful completion, ulimit() shall return the value of the
53 requested limit. Otherwise, −1 shall be returned and errno set to indi‐
54 cate the error.
55
57 The ulimit() function shall fail and the limit shall be unchanged if:
58
59 EINVAL The cmd argument is not valid.
60
61 EPERM A process not having appropriate privileges attempts to increase
62 its file size limit.
63
64 The following sections are informative.
65
67 None.
68
70 Since the ulimit() function uses type long rather than rlim_t, this
71 function is not sufficient for file sizes on many current systems.
72 Applications should use the getrlimit() or setrlimit() functions
73 instead of the obsolescent ulimit() function.
74
76 None.
77