1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1982-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * David Korn <dgk@research.att.com> *
19 ***********************************************************************/
24 * This is for the ulimit built-in command
27 #include "FEATURE/time"
28 #include "FEATURE/rlimits"
29 #if defined(_sys_resource) && defined(_lib_getrlimit)
30 # include <sys/resource.h>
31 # if !defined(RLIMIT_FSIZE) && defined(_sys_vlimit)
32 /* This handles hp/ux problem */
33 # include <sys/vlimit.h>
34 # define RLIMIT_FSIZE (LIM_FSIZE-1)
35 # define RLIMIT_DATA (LIM_DATA-1)
36 # define RLIMIT_STACK (LIM_STACK-1)
37 # define RLIMIT_CORE (LIM_CORE-1)
38 # define RLIMIT_CPU (LIM_CPU-1)
40 # define RLIMIT_RSS (LIM_MAXRSS-1)
41 # endif /* LIM_MAXRSS */
46 # include <sys/vlimit.h>
48 # define RLIMIT_FSIZE LIM_FSIZE
49 # define RLIMIT_DATA LIM_DATA
50 # define RLIMIT_STACK LIM_STACK
51 # define RLIMIT_CORE LIM_CORE
52 # define RLIMIT_CPU LIM_CPU
54 # define RLIMIT_RSS LIM_MAXRSS
55 # endif /* LIM_MAXRSS */
58 # define vlimit ulimit
59 # endif /* _lib_ulimit */
60 # endif /* _lib_vlimit */
64 # define INFINITY RLIM_INFINITY
67 # define INFINITY ((rlim_t)-1L)
68 # endif /* INFINITY */
69 #endif /* RLIM_INFINITY */
71 #if defined(_lib_getrlimit) || defined(_lib_vlimit) || defined(_lib_ulimit)
74 # endif /* !RLIMIT_CPU */
76 # define RLIMIT_DATA 0
77 # endif /* !RLIMIT_DATA */
80 # endif /* !RLIMIT_RSS */
82 # define RLIMIT_STACK 0
83 # endif /* !RLIMIT_STACK */
85 # define RLIMIT_CORE 0
86 # endif /* !RLIMIT_CORE */
88 # define RLIMIT_VMEM 0
89 # endif /* !RLIMIT_VMEM */
90 # ifndef RLIMIT_NOFILE
91 # define RLIMIT_NOFILE 0
92 # endif /* !RLIMIT_NOFILE */
100 #if !defined(RLIMIT_NOFILE) && defined(RLIMIT_OFILE)
101 #define RLIMIT_NOFILE RLIMIT_OFILE
104 #ifndef RLIMIT_UNKNOWN
105 #define RLIMIT_UNKNOWN (-9999)
108 #define RLIMIT_AS RLIMIT_UNKNOWN
111 #define RLIMIT_CORE RLIMIT_UNKNOWN
114 #define RLIMIT_CPU RLIMIT_UNKNOWN
117 #define RLIMIT_DATA RLIMIT_UNKNOWN
120 #define RLIMIT_FSIZE RLIMIT_UNKNOWN
123 #define RLIMIT_LOCKS RLIMIT_UNKNOWN
125 #ifndef RLIMIT_MEMLOCK
126 #define RLIMIT_MEMLOCK RLIMIT_UNKNOWN
128 #ifndef RLIMIT_NOFILE
129 #define RLIMIT_NOFILE RLIMIT_UNKNOWN
132 #define RLIMIT_NPROC RLIMIT_UNKNOWN
135 #define RLIMIT_PIPE RLIMIT_UNKNOWN
138 #define RLIMIT_RSS RLIMIT_UNKNOWN
140 #ifndef RLIMIT_SBSIZE
141 #define RLIMIT_SBSIZE RLIMIT_UNKNOWN
144 #define RLIMIT_STACK RLIMIT_UNKNOWN
146 #ifndef RLIMIT_PTHREAD
147 #define RLIMIT_PTHREAD RLIMIT_UNKNOWN
150 #define RLIMIT_VMEM RLIMIT_UNKNOWN
159 typedef struct Limit_s
162 const char* description
;
165 unsigned char option
;
169 extern const Limit_t shtab_limits
[];
170 extern const int shtab_units
[];
172 extern const char e_unlimited
[];
173 extern const char* e_units
[];
175 #endif /* _ULIMIT_H */