⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 syscalls_88.html

📁 Linux系统调用
💻 HTML
字号:
<!-- This HTML file has been created by texi2html 1.29
     from syscalls.texi on 4 June 1994 -->

<TITLE>Syscall specifications of Linux - getrlimit</TITLE>
<P>Go to the <A HREF="syscalls_87.html" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_87.html">previous</A>, <A HREF="syscalls_89.html" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_89.html">next</A> section.<P>
<H2><A NAME="SEC88" HREF="syscalls_toc.html#SEC88" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_toc.html#SEC88">getrlimit, getrusage and setrlimit</A></H2>
<P>
<H3>SYNOPSIS</H3>
<P>
<CODE>int getrlimit (int <VAR>resource</VAR>, struct rlimit *<VAR>rlim</VAR>);</CODE>
<P>
<CODE>int getrusage (int <VAR>who</VAR>, struct rusage *<VAR>usage</VAR>);</CODE>
<P>
<CODE>int setrlimit (int <VAR>resource</VAR>, const struct rlimit *<VAR>rlim</VAR>);</CODE>
<P>
<H3>PARAMETERS</H3>
<P>
<VAR>resource</VAR>: [in] which resource to access.
<P>
<VAR>rlim</VAR>: (For <CODE>getrlimit</CODE>) [in] points to a buffer where to put
the limit. (For <CODE>setrlimit</CODE>) [out] points to a buffer where the new
limits are.
<P>
<VAR>who</VAR>: [in] specifies from what process(es) we want to get the
ressource usage.
<P>
<VAR>usage</VAR>: [out] points to a buffer where the ressource usage is saved.
<P>
<H3>DESCRIPTION</H3>
<P>
<CODE>getrlimit</CODE> gets the resources limits and <CODE>setrlimit</CODE> sets
them. The <VAR>resource</VAR> variable is one of:
<P>
<DL COMPACT>
<DT><CODE>RLIMIT_CPU</CODE>
<DD>CPU time in miliseconds.
<P>
<DT><CODE>RLIMIT_FSIZE</CODE>
<DD>The maximum file size (in bytes).
<P>
<DT><CODE>RLIMIT_DATA</CODE>
<DD>The maximum data size (in bytes).
<P>
<DT><CODE>RLIMIT_STACK</CODE>
<DD>The maximum stack size (in bytes).
<P>
<DT><CODE>RLIMIT_CORE</CODE>
<DD>The maximum core file size (in bytes).
<P>
<DT><CODE>RLIMIT_RSS</CODE>
<DD>The maximum resident set size (in bytes).
</DL>
<P>
Privision is made for a future implementation of the additionnal
following values of <VAR>resource</VAR>:
<P>
<DL COMPACT>
<DT><CODE>RLIMIT_MEMLOCK</CODE>
<DD>The maximum size of wired memory space.
<P>
<DT><CODE>RLIMIT_NPROC</CODE>
<DD>The maximum number of processes.
<P>
<DT><CODE>RLIMIT_OFILE</CODE>
<DD>The maximum number of opened files.
</DL>
<P>
The <CODE>rlimit</CODE> structure has the following format:
<P>
<PRE>
struct rlimit {
        int     rlim_cur; /* current limit */
        int     rlim_max; /* maximum limit */
};
</PRE>
<P>
By setting the limit to <CODE>RLIM_INFINITY</CODE> a limit can be set to
infinity.
<P>
<CODE>getrusage</CODE> gets the ressource usage of the current task (for
<VAR>who</VAR> set to <CODE>RUSAGE_SELF</CODE>) or of the child of the current task
(for <VAR>who</VAR> set to <CODE>RUSAGE_CHILDREN</CODE>). The rusage structure has
the following definition:
<P>
<PRE>
struct  rusage {
        struct timeval ru_utime;        /* user time used */
        struct timeval ru_stime;        /* system time used */
        long    ru_maxrss;              /* maximum resident set size */
        long    ru_ixrss;               /* integral shared memory size */
        long    ru_idrss;               /* integral unshared data size */
        long    ru_isrss;               /* integral unshared stack size */
        long    ru_minflt;              /* page reclaims */
        long    ru_majflt;              /* page faults */
        long    ru_nswap;               /* swaps */
        long    ru_inblock;             /* block input operations */
        long    ru_oublock;             /* block output operations */
        long    ru_msgsnd;              /* messages sent */
        long    ru_msgrcv;              /* messages received */
        long    ru_nsignals;            /* signals received */
        long    ru_nvcsw;               /* voluntary context switches */
        long    ru_nivcsw;              /* involuntary " */
};
</PRE>
<P>
<H3>RETURN VALUE</H3>
<P>
On success zero is returned. On error -1 is returned and <CODE>errno</CODE> is
set to one of the following values:
<P>
For <CODE>setrlimit</CODE>: <CODE>EPERM</CODE> if the task does not have superuser
privileges.
<P>
For <CODE>setrlimit</CODE> and <CODE>getrlimit</CODE>: <CODE>EINVAL</CODE> if the
<VAR>ressource</VAR> value is invalid.
<P>
For <CODE>getrusage</CODE>: <CODE>EINVAL</CODE> if the <VAR>who</VAR> value is invalid.
<P>
<P>Go to the <A HREF="syscalls_87.html" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_87.html">previous</A>, <A HREF="syscalls_89.html" tppabs="http://personal.xfol.com/%7erezaie/syscall/syscalls_89.html">next</A> section.<P>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -