Update.
[glibc.git] / resource / sys / resource.h
blob3d0e5a921b5904b3be4791b8ed3626a98814e181
1 /* Copyright (C) 1992, 1994, 1996 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If
16 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17 Cambridge, MA 02139, USA. */
19 #ifndef _SYS_RESOURCE_H
21 #define _SYS_RESOURCE_H 1
22 #include <features.h>
24 __BEGIN_DECLS
26 /* Get the system-dependent definitions of RLIM_*. */
27 #include <resourcebits.h>
29 struct rlimit
31 /* The current (soft) limit. */
32 int rlim_cur;
33 /* The hard limit. */
34 int rlim_max;
37 /* Value used to indicate that there is no limit. */
38 #define RLIM_INFINITY 0x7fffffff
40 /* Put the soft and hard limits for RESOURCE in *RLIMITS.
41 Returns 0 if successful, -1 if not (and sets errno). */
42 extern int __getrlimit __P ((enum __rlimit_resource __resource,
43 struct rlimit *__rlimits));
44 extern int getrlimit __P ((enum __rlimit_resource __resource,
45 struct rlimit *__rlimits));
47 /* Set the soft and hard limits for RESOURCE to *RLIMITS.
48 Only the super-user can increase hard limits.
49 Return 0 if successful, -1 if not (and sets errno). */
50 extern int setrlimit __P ((enum __rlimit_resource __resource,
51 struct rlimit *__rlimits));
54 /* Whose usage statistics do you want? */
55 enum __rusage_who
56 /* The macro definitions are necessary because some programs want
57 to test for operating system features with #ifdef RUSAGE_SELF.
58 In ANSI C the reflexive definition is a no-op. */
60 /* The calling process. */
61 RUSAGE_SELF = 0,
62 #define RUSAGE_SELF RUSAGE_SELF
63 /* All of its terminated child processes. */
64 RUSAGE_CHILDREN = -1
65 #define RUSAGE_CHILDREN RUSAGE_CHILDREN
68 #include <sys/time.h> /* For `struct timeval'. */
70 /* Structure which says how much of each resource has been used. */
71 struct rusage
73 /* Total amount of user time used. */
74 struct timeval ru_utime;
75 /* Total amount of system time used. */
76 struct timeval ru_stime;
77 /* Maximum resident set size (in kilobytes). */
78 long ru_maxrss;
79 /* Amount of sharing of text segment memory
80 with other processes (kilobyte-seconds). */
81 long ru_ixrss;
82 /* Amount of data segment memory used (kilobyte-seconds). */
83 long ru_idrss;
84 /* Amount of stack memory used (kilobyte-seconds). */
85 long ru_isrss;
86 /* Number of soft page faults (i.e. those serviced by reclaiming
87 a page from the list of pages awaiting reallocation. */
88 long ru_minflt;
89 /* Number of hard page faults (i.e. those that required I/O). */
90 long ru_majflt;
91 /* Number of times a process was swapped out of physical memory. */
92 long ru_nswap;
93 /* Number of input operations via the file system. Note: This
94 and `ru_oublock' do not include operations with the cache. */
95 long ru_inblock;
96 /* Number of output operations via the file system. */
97 long ru_oublock;
98 /* Number of IPC messages sent. */
99 long ru_msgsnd;
100 /* Number of IPC messages received. */
101 long ru_msgrcv;
102 /* Number of signals delivered. */
103 long ru_nsignals;
104 /* Number of voluntary context switches, i.e. because the process
105 gave up the process before it had to (usually to wait for some
106 resource to be available). */
107 long ru_nvcsw;
108 /* Number of involuntary context switches, i.e. a higher priority process
109 became runnable or the current process used up its time slice. */
110 long ru_nivcsw;
113 /* Return resource usage information on process indicated by WHO
114 and put it in *USAGE. Returns 0 for success, -1 for failure. */
115 extern int __getrusage __P ((enum __rusage_who __who, struct rusage *__usage));
116 extern int getrusage __P ((enum __rusage_who __who, struct rusage *__usage));
118 /* Function depends on CMD:
119 1 = Return the limit on the size of a file, in units of 512 bytes.
120 2 = Set the limit on the size of a file to NEWLIMIT. Only the
121 super-user can increase the limit.
122 3 = Return the maximum possible address of the data segment.
123 4 = Return the maximum number of files that the calling process can open.
124 Returns -1 on errors. */
125 extern long int __ulimit __P ((int __cmd, long int __newlimit));
126 extern long int ulimit __P ((int __cmd, long int __newlimit));
129 /* Priority limits. */
130 #define PRIO_MIN -20 /* Minimum priority a process can have. */
131 #define PRIO_MAX 20 /* Maximum priority a process can have. */
133 /* The type of the WHICH argument to `getpriority' and `setpriority',
134 indicating what flavor of entity the WHO argument specifies. */
135 enum __priority_which
137 PRIO_PROCESS = 0, /* WHO is a process ID. */
138 PRIO_PGRP = 1, /* WHO is a process group ID. */
139 PRIO_USER = 2 /* WHO is a user ID. */
142 /* Return the highest priority of any process specified by WHICH and WHO
143 (see above); if WHO is zero, the current process, process group, or user
144 (as specified by WHO) is used. A lower priority number means higher
145 priority. Priorities range from PRIO_MIN to PRIO_MAX (above). */
146 extern int getpriority __P ((enum __priority_which __which, int __who));
148 /* Set the priority of all processes specified by WHICH and WHO (see above)
149 to PRIO. Returns 0 on success, -1 on errors. */
150 extern int setpriority __P ((enum __priority_which __which, int __who,
151 int __prio));
154 __END_DECLS
156 #endif /* resource.h */