.\" Hey Emacs! This file is -*- nroff -*- source. .\" .\" Copyright (c) 1992 Drew Eckhardt, March 28, 1992 .\" and Copyright (c) 2002, 2004, 2005, 2008 Michael Kerrisk .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .\" Modified by Michael Haardt .\" Modified 1993-07-23 by Rik Faith .\" Modified 1996-01-13 by Arnt Gulbrandsen .\" Modified 1996-01-22 by aeb, following a remark by .\" Tigran Aivazian .\" Modified 1996-04-14 by aeb, following a remark by .\" Robert Bihlmeyer .\" Modified 1996-10-22 by Eric S. Raymond .\" Modified 2001-05-04 by aeb, following a remark by .\" Havard Lygre .\" Modified 2001-04-17 by Michael Kerrisk .\" Modified 2002-06-13 by Michael Kerrisk .\" Added note on nonstandard behavior when SIGCHLD is ignored. .\" Modified 2002-07-09 by Michael Kerrisk .\" Enhanced descriptions of 'resource' values for [gs]etrlimit() .\" Modified 2003-11-28 by aeb, added RLIMIT_CORE .\" Modified 2004-03-26 by aeb, added RLIMIT_AS .\" Modified 2004-06-16 by Michael Kerrisk .\" Added notes on CAP_SYS_RESOURCE .\" .\" 2004-11-16 -- mtk: the getrlimit.2 page, which formally included .\" coverage of getrusage(2), has been split, so that the latter .\" is now covered in its own getrusage.2. .\" .\" Modified 2004-11-16, mtk: A few other minor changes .\" Modified 2004-11-23, mtk .\" Added notes on RLIMIT_MEMLOCK, RLIMIT_NPROC, and RLIMIT_RSS .\" to "CONFORMING TO" .\" Modified 2004-11-25, mtk .\" Rewrote discussion on RLIMIT_MEMLOCK to incorporate kernel .\" 2.6.9 changes. .\" Added note on RLIMIT_CPU error in older kernels .\" 2004-11-03, mtk, Added RLIMIT_SIGPENDING .\" 2005-07-13, mtk, documented RLIMIT_MSGQUEUE limit. .\" 2005-07-28, mtk, Added descriptions of RLIMIT_NICE and RLIMIT_RTPRIO .\" 2008-05-07, mtk / Peter Zijlstra, Added description of RLIMIT_RTTIME .\" .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya .\" all rights reserved. .\" Translated 1997-02-22, HANATAKA Shinya .\" Updated and Modified 2001-06-02, Yuichi SATO .\" Updated and Modified 2001-08-18, Yuichi SATO .\" Updated and Modified 2002-08-25, Yuichi SATO .\" Updated and Modified 2004-01-17, Yuichi SATO .\" Updated and Modified 2004-12-30, Yuichi SATO .\" Updated and Modified 2005-09-10, Yuichi SATO .\" Updated and Modified 2005-10-11, Akihiro MOTOKI .\" Updated and Modified 2005-10-27, Akihiro MOTOKI .\" Updated and Modified 2006-04-15, Akihiro MOTOKI, Catch up to LDP v2.29 .\" Updated 2008-08-08, Akihiro MOTOKI, LDP v3.05 .\" Updated 2008-10-13, Akihiro MOTOKI, LDP v3.11 .\" .\"WORD: resource 資源 .\"WORD: limit 制限 .\" .TH GETRLIMIT 2 2010-09-26 "Linux" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O getrlimit, setrlimit \- get/set resource limits getrlimit, setrlimit \- 資源の制限を取得/設定する .\"O .SH SYNOPSIS .SH 書式 .B #include .br .B #include .sp .BI "int getrlimit(int " resource ", struct rlimit *" rlim ); .br .BI "int setrlimit(int " resource ", const struct rlimit *" rlim ); .\"O .SH DESCRIPTION .SH 説明 .\"O .BR getrlimit () .\"O and .\"O .BR setrlimit () .\"O get and set resource limits respectively. .BR getrlimit () と .BR setrlimit () はそれぞれ資源 (resource) の制限 (limit) の設定と取得を行う。 .\"O Each resource has an associated soft and hard limit, as defined by the .\"O .I rlimit .\"O structure (the .\"O .I rlim .\"O argument to both .\"O .BR getrlimit () .\"O and .\"O .BR setrlimit ()): 各リソースには、それに対応するソフト・リミットとハード・リミットがある。 リミットは .RB ( getrlimit () と .BR setrlimit () の .I rlim 引き数である) .I rlimit 構造体で定義される: .PP .in +4n .nf struct rlimit { .\"O rlim_t rlim_cur; /* Soft limit */ .\"O rlim_t rlim_max; /* Hard limit (ceiling for rlim_cur) */ rlim_t rlim_cur; /* ソフト・リミット */ rlim_t rlim_max; /* ハード・リミット (rlim_cur より小さくない) */ }; .fi .in .\"O The soft limit is the value that the kernel enforces for the .\"O corresponding resource. ソフト・リミットは、カーネルが対応するリソースに対して課す制限値である。 .\"O The hard limit acts as a ceiling for the soft limit: ハード・リミットはソフト・リミットの上限として働く。 .\"O an unprivileged process may only set its soft limit to a value in the .\"O range from 0 up to the hard limit, and (irreversibly) lower its hard limit. 特権を持たないプロセスは、ソフト・リミットの値を 0 からハード・リミットの範囲に設定することと、 ハード・リミットを下げることのみができる (一度下げたハードリミットは上げられない)。 .\"O A privileged process (under Linux: one with the .\"O .B CAP_SYS_RESOURCE .\"O capability) may make arbitrary changes to either limit value. 特権プロセス (Linux では .B CAP_SYS_RESOURCE ケーパビリティ (capability) を持つプロセス) は ソフト・リミットとハード・リミットを自由に変更できる。 .PP .\"O The value .\"O .B RLIM_INFINITY .\"O denotes no limit on a resource (both in the structure returned by .\"O .BR getrlimit () .\"O and in the structure passed to .\"O .BR setrlimit ()). 値 .B RLIM_INFINITY はリソースに制限がないことを表す (この値は .BR getrlimit () が返す構造体と .BR setrlimit () に渡す構造体の両方で使用される)。 .PP .\"O .I resource .\"O must be one of: .I resource は次のいずれか 1 つである。 .TP .B RLIMIT_AS .\"O The maximum size of the process's virtual memory (address space) in bytes. プロセスの仮想メモリ (アドレス空間) の最大サイズ (バイト単位)。 .\"O .\" since 2.0.27 / 2.1.12 .\" 2.0.27 / 2.1.12 以降。 .\"O This limit affects calls to .\"O .BR brk (2), .\"O .BR mmap (2) .\"O and .\"O .BR mremap (2), .\"O which fail with the error .\"O .B ENOMEM .\"O upon exceeding this limit. .\"O Also automatic stack expansion will fail .\"O (and generate a .\"O .B SIGSEGV .\"O that kills the process if no alternate stack .\"O has been made available via .\"O .BR sigaltstack (2)). この制限は .BR brk (2), .BR mmap (2), .BR mremap (2) の呼び出しに影響し、この制限を超えた場合は エラー .B ENOMEM で失敗する。 また自動的なスタック拡張にも失敗する (さらに .BR sigaltstack (2) を使った代替スタックを利用可能にしていなかった場合には、 .B SIGSEGV を生成してそのプロセスを kill する)。 .\"O Since the value is a \fIlong\fP, on machines with a 32-bit \fIlong\fP .\"O either this limit is at most 2 GiB, or this resource is unlimited. この値は \fIlong\fP 型なので、32 ビットの \fIlong\fP 型を持つマシンでは、 この制限は最大で 2 GiB になるか、この資源が無制限になる。 .TP .B RLIMIT_CORE .\"O Maximum size of .\"O .I core .\"O file. .\"O When 0 no core dump files are created. .I core ファイルの最大サイズ。 0 の場合、core ファイルは生成されない。 .\"O When nonzero, larger dumps are truncated to this size. 0 以外の場合、このサイズより大きいダンプは切り詰められる。 .TP .B RLIMIT_CPU .\"O CPU time limit in seconds. CPU 時間の上限 (秒数)。 .\"O When the process reaches the soft limit, it is sent a .\"O .B SIGXCPU .\"O signal. プロセスがソフト・リミットに達した場合に、 .B SIGXCPU シグナルを送る。 .\"O The default action for this signal is to terminate the process. このシグナルに対するデフォルトの動作は、プロセスの終了である。 .\"O However, the signal can be caught, and the handler can return control to .\"O the main program. ただしシグナルをキャッチして、ハンドラがメインプログラムに 制御を返すこともできる。 .\"O If the process continues to consume CPU time, it will be sent .\"O .B SIGXCPU .\"O once per second until the hard limit is reached, at which time .\"O it is sent .\"O .BR SIGKILL . プロセスが CPU 時間を使い続けた場合は、 ハードリミットに達するまで 1 秒毎にプロセスに .B SIGXCPU を送り、 ハードリミットに達すると .B SIGKILL を送る。 .\"O (This latter point describes Linux 2.2 through 2.6 behavior. ソフト・リミットを超過したときの動作は、 Linux 2.2 から 2.6 のものである。 .\"O Implementations vary in how they treat processes which continue to .\"O consume CPU time after reaching the soft limit. ソフト・リミットを超えて CPU 時間を使い続けるプロセスの 扱い方についての実装は変化してきている。 .\"O Portable applications that need to catch this signal should .\"O perform an orderly termination upon first receipt of .\"O .BR SIGXCPU .) このシグナルをキャッチする必要のある 移植性を考えたアプリケーションでは、 最初に .B SIGXCPU を受け取った時点で正しく終了すべきである。 .TP .B RLIMIT_DATA .\"O The maximum size of the process's data segment (initialized data, .\"O uninitialized data, and heap). プロセスのデータセグメント (初期化されたデータ・初期化されていないデータ・ヒープ) の最大値。 .\"O This limit affects calls to .\"O .BR brk (2) .\"O and .\"O .BR sbrk (2), .\"O which fail with the error .\"O .B ENOMEM .\"O upon encountering the soft limit of this resource. このリミットは .BR brk (2) と .BR sbrk (2) の呼び出しに影響する。 これらの関数は、このリソースのソフト・リミットに達すると、 エラー .B ENOMEM で失敗する。 .TP .B RLIMIT_FSIZE .\"O The maximum size of files that the process may create. プロセスが作成できるファイルサイズの最大値。 .\"O Attempts to extend a file beyond this limit result in delivery of a .\"O .B SIGXFSZ .\"O signal. このサイズを超えてファイルを拡張すると、 .B SIGXFSZ シグナルを送る。 .\"O By default, this signal terminates a process, but a process can .\"O catch this signal instead, in which case the relevant system call (e.g., .\"O .BR write (2), .\"O .BR truncate (2)) .\"O fails with the error .\"O .BR EFBIG . デフォルトでは、このシグナルはプロセスを終了する。 プロセスをキャッチすることもできるが、 関連するシステムコール .RB ( write (2), .BR truncate (2) など) はエラー .B EFBIG で失敗する。 .TP .\"O .BR RLIMIT_LOCKS " (Early Linux 2.4 only)" .BR RLIMIT_LOCKS " (初期の Linux 2.4 のみ)" .\"O .\" to be precise: Linux 2.4.0-test9; no longer in 2.4.25 / 2.5.65 .\" 正確には Linux 2.4.0-test9 のみ。2.4.25 / 2.5.65 ではなくなっている。 .\"O A limit on the combined number of .\"O .BR flock (2) .\"O locks and .\"O .BR fcntl (2) .\"O leases that this process may establish. このプロセスが実行できる .BR flock (2) ロック数と .BR fcntl (2) リース数の合計値を制限する。 .TP .B RLIMIT_MEMLOCK .\"O The maximum number of bytes of memory that may be locked .\"O into RAM. RAM 内にロックできるメモリの最大バイト数。 .\"O In effect this limit is rounded down to the nearest multiple .\"O of the system page size. 実際には、この制限はシステムページサイズの最も近い倍数に 切り捨てて丸められる。 .\"O This limit affects .\"O .BR mlock (2) .\"O and .\"O .BR mlockall (2) .\"O and the .\"O .BR mmap (2) .\"O .B MAP_LOCKED .\"O operation. この制限は .BR mlock (2), .BR mlockall (2), .BR mmap (2) の .B MAP_LOCKED 操作に影響する。 .\"O Since Linux 2.6.9 it also affects the .\"O .BR shmctl (2) .\"O .B SHM_LOCK .\"O operation, where it sets a maximum on the total bytes in .\"O shared memory segments (see .\"O .BR shmget (2)) .\"O that may be locked by the real user ID of the calling process. Linux 2.6.9 以降では .BR shmctl (2) .B SHM_LOCK 操作にも影響する。 この操作は呼び出し元プロセスの実 (real) ユーザー ID にロックされる 共有メモリセグメント .RB ( shmget (2) を参照) の合計バイト数の最大値を設定する。 .\"O The .\"O .BR shmctl (2) .\"O .B SHM_LOCK .\"O locks are accounted for separately from the per-process memory .\"O locks established by .\"O .BR mlock (2), .\"O .BR mlockall (2), .\"O and .\"O .BR mmap (2) .\"O .BR MAP_LOCKED ; .\"O a process can lock bytes up to this limit in each of these .\"O two categories. .BR shmctl (2) .B SHM_LOCK によるロックは、 .BR mlock (2), .BR mlockall (2), .BR mmap (2) の .B MAP_LOCKED によって確立されるプロセス毎のメモリロックとは分けて数える。 1 つのプロセスはこの制限までのバイトをロックできる。 この制限には 2 つの種類がある。 .\"O In Linux kernels before 2.6.9, this limit controlled the amount of .\"O memory that could be locked by a privileged process. 2.6.9 より前の Linux カーネル では、 この制限は特権プロセスによってロックされるメモリの合計を制御していた。 .\"O Since Linux 2.6.9, no limits are placed on the amount of memory .\"O that a privileged process may lock, and this limit instead governs .\"O the amount of memory that an unprivileged process may lock. Linux 2.6.9 以降では、特権プロセスがロックするメモリの合計に制限はなく、 代わりにこの制限は非特権プロセスがロックするメモリの合計に 適用されるようになった。 .TP .\"O .BR RLIMIT_MSGQUEUE " (Since Linux 2.6.8)" .BR RLIMIT_MSGQUEUE " (Linux 2.6.8 以降)" .\"O Specifies the limit on the number of bytes that can be allocated .\"O for POSIX message queues for the real user ID of the calling process. .\"O This limit is enforced for .\"O .BR mq_open (3). 呼び出し元プロセスの実ユーザー ID に対して、 POSIX メッセージキューのために確保できるバイト数の制限を指定する。 この制限は .BR mq_open (3) に対して適用される。 .\"O Each message queue that the user creates counts (until it is removed) .\"O against this limit according to the formula: ユーザが作成した各々のメッセージキューのバイト数は 以下の式により計算され、(そのキューが削除されるまでの間) この制限の計算対象に含められる。 .nf bytes = attr.mq_maxmsg * sizeof(struct msg_msg *) + attr.mq_maxmsg * attr.mq_msgsize .fi .\"O where .\"O .I attr .\"O is the .\"O .I mq_attr .\"O structure specified as the fourth argument to .\"O .BR mq_open (3). ここで .I attr は .I mq_attr 構造体であり、 .BR mq_open (3) の第 4 引き数として指定される。 .\"O The first addend in the formula, which includes .\"O .I "sizeof(struct msg_msg *)" .\"O (4 bytes on Linux/i386), ensures that the user cannot .\"O create an unlimited number of zero-length messages (such messages .\"O nevertheless each consume some system memory for bookkeeping overhead). .I "sizeof(struct msg_msg *)" (Linux/i386 では 4 バイト) を含む最初の加数は、 ユーザーが長さ 0 のメッセージを無制限に作れないこと保証している (このようなメッセージであっても、 記録のためのオーバーヘッドでシステムメモリを消費する)。 .TP .\"O .BR RLIMIT_NICE " (since Linux 2.6.12, but see BUGS below)" .BR RLIMIT_NICE " (Linux 2.6.12 以降, 下記の「バグ」の節も参照)" .\"O Specifies a ceiling to which the process's nice value can be raised using .\"O .BR setpriority (2) .\"O or .\"O .BR nice (2). .\"O The actual ceiling for the nice value is calculated as .\"O .IR "20\ \-\ rlim_cur" . .\"O (This strangeness occurs because negative numbers cannot be specified .\"O as resource limit values, since they typically have special meanings. .\"O For example, .\"O .B RLIM_INFINITY .\"O typically is the same as \-1.) .BR setpriority (2) や .BR nice (2) を使って引き上げられるプロセスの nice 値の上限を指定する。 nice 値の実際の上限は .I "20\ \-\ rlim_cur" で計算される (このような変な状況は、リソース制限値として負の数を指定できないため 発生する。通常、負の値は特別な意味を持っているからである。 例えば、通常は .B RLIM_INFINITY の値は \-1 である)。 .TP .B RLIMIT_NOFILE .\"O Specifies a value one greater than the maximum file descriptor number .\"O that can be opened by this process. このプロセスがオープンできるファイルディスクリプタ数の最大値より 1 大きい値を指定する。 .\"O Attempts .\"O .RB ( open (2), .\"O .BR pipe (2), .\"O .BR dup (2), .\"O etc.) .\"O to exceed this limit yield the error .\"O .BR EMFILE . .\"O (Historically, this limit was named .\"O .B RLIMIT_OFILE .\"O on BSD.) .RB ( open (2), .BR pipe (2), .BR dup (2) などにより) この上限を超えようとした場合、エラー .B EMFILE が発生する (歴史的に、BSD ではこの上限は .B RLIMIT_OFILE という名前となっている)。 .TP .B RLIMIT_NPROC .\"O The maximum number of processes (or, more precisely on Linux, threads) .\"O that can be created for the real user ID of the calling process. .\"O Upon encountering this limit, .\"O .BR fork (2) .\"O fails with the error .\"O .BR EAGAIN . 呼び出したプロセスの実ユーザー ID で作成できる最大プロセス数 (より正確には Linux ではスレッド数)。 この上限に達すると、 .BR fork (2) はエラー .B EAGAIN で失敗する。 .TP .B RLIMIT_RSS .\"O Specifies the limit (in pages) of the process's resident set .\"O (the number of virtual pages resident in RAM). プロセスの resident set (RAM 上に存在する仮想ページの数) の 上限を (ページ数で) 指定する。 .\"O This limit only has effect in Linux 2.4.x, x < 30, and there only .\"O affects calls to .\"O .BR madvise (2) .\"O specifying .\"O .BR MADV_WILLNEED . この制限は 2.4.30 より前でしか影響がなく、 .BR madvise (2) に .B MADV_WILLNEED を指定した関数コールにしか影響しない。 .\"O .\" As at kernel 2.6.12, this limit still does nothing in 2.6 though .\"O .\" talk of making it do something has surfaced from time to time in LKML .\" カーネル 2.6.12 の時点では、 .\" この制限はカーネル 2.6 ではまだ何も行わない。 .\" しかし、何をさせるかについては LKML で時々話題になっている。 .\" -- MTK, Jul 05 .TP .\"O .BR RLIMIT_RTPRIO " (Since Linux 2.6.12, but see BUGS)" .BR RLIMIT_RTPRIO " (Linux 2.6.12 以降, バグの節も参照)" .\"O Specifies a ceiling on the real-time priority that may be set for .\"O this process using .\"O .BR sched_setscheduler (2) .\"O and .\"O .BR sched_setparam (2). .BR sched_setscheduler (2) や .BR sched_setparam (2) を使って設定できる、そのプロセスのリアルタイム優先度の上限を指定する。 .TP .\"O .BR RLIMIT_RTTIME " (Since Linux 2.6.25)" .BR RLIMIT_RTTIME " (Linux 2.6.25 以降)" .\"O Specifies a limit (in microseconds) .\"O on the amount of CPU time that a process scheduled .\"O under a real-time scheduling policy may consume without making a blocking .\"O system call. .\"O For the purpose of this limit, .\"O each time a process makes a blocking system call, .\"O the count of its consumed CPU time is reset to zero. .\"O The CPU time count is not reset if the process continues trying to .\"O use the CPU but is preempted, its time slice expires, or it calls .\"O .BR sched_yield (2). リアルタイム・スケジューリング方針でスケジューリングされるプロセスが ブロッキング型のシステムコールを呼び出さずに消費することのできる CPU 時間の合計についての上限を (マイクロ秒単位で) 指定する。 この上限の目的のため、プロセスがブロッキング型のシステムコールを 呼び出す度に、消費された CPU 時間のカウントは 0 にリセットされる。 プロセスが CPU を使い続けようとしたが他のプロセスに置き換えられた (preempted) 場合や、そのプロセスのタイムスライスが満了した場合、 そのプロセスが .BR sched_yield (2) を呼び出した場合は、CPU 時間のカウントはリセットされない。 .\"O Upon reaching the soft limit, the process is sent a .\"O .B SIGXCPU .\"O signal. .\"O If the process catches or ignores this signal and .\"O continues consuming CPU time, then .\"O .B SIGXCPU .\"O will be generated once each second until the hard limit is reached, .\"O at which point the process is sent a .\"O .B SIGKILL .\"O signal. ソフト・リミットに達すると、そのプロセスに .B SIGXCPU シグナルが送られる。そのプロセスがこのシグナルを捕捉するか 無視して、CPU 時間を消費し続けた場合には、 ハード・リミットに達するまで 1 秒に 1 回 .B SIGXCPU が生成され続けることになる。 ハード・リミットに達した時点で、そのプロセスには .B SIGKILL シグナルが送られる。 .\"O The intended use of this limit is to stop a runaway .\"O real-time process from locking up the system. この上限を意図的に使用するのは、暴走したリアルタイム・プロセスを 停止して、システムが動かなくなるのを避ける場合である。 .TP .\"O .BR RLIMIT_SIGPENDING " (Since Linux 2.6.8)" .BR RLIMIT_SIGPENDING " (Linux 2.6.8 以降)" .\"O Specifies the limit on the number of signals .\"O that may be queued for the real user ID of the calling process. 呼び出し元プロセスの実ユーザー ID に対して キューに入れられるシグナルの数の制限を指定する。 .\"O Both standard and real-time signals are counted for the purpose of .\"O checking this limit. この制限をチェックするため、 標準シグナルとリアルタイム・シグナルの両方がカウントされる。 .\"O However, the limit is only enforced for .\"O .BR sigqueue (2); .\"O it is always possible to use .\"O .BR kill (2) .\"O to queue one instance of any of the signals that are not already .\"O queued to the process. しかし、この制限は .BR sigqueue (2) に対してしか強制されず、 .BR kill (2) 使うことで、そのプロセスに対してまだキューに入れられていない シグナルのインスタンスをキューに入れることができる。 .\"O .\" This replaces the /proc/sys/kernel/rtsig-max system-wide limit .\"O .\" that was present in kernels <= 2.6.7. MTK Dec 04 .\" これはカーネル 2.6.7 以前に存在するシステム全体の制限 .\" /proc/sys/kernel/rtsig-max を置き換える。MTK Dec 04 .TP .B RLIMIT_STACK .\"O The maximum size of the process stack, in bytes. プロセス・スタックの最大サイズをバイト単位で指定する。 .\"O Upon reaching this limit, a .\"O .B SIGSEGV .\"O signal is generated. この上限に達すると、 .B SIGSEGV シグナルが生成される。 .\"O To handle this signal, a process must employ an alternate signal stack .\"O .RB ( sigaltstack (2)). このシグナルを扱うためには、 プロセスは代りのシグナルスタック .RB ( sigaltstack (2)) を使用しなければならない。 .\"O Since Linux 2.6.23, .\"O this limit also determines the amount of space used for the process's .\"O command-line arguments and environment variables; for details, see .\"O .BR execve (2). Linux 2.6.23 以降では、この制限はプロセスのコマンドライン引き数と環境変数 に使用される空間の合計サイズの上限の決定にも使用される。詳細については .BR execve (2) を参照。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O On success, zero is returned. .\"O On error, \-1 is returned, and .\"O .I errno .\"O is set appropriately. 成功した場合は 0 が返される。エラーの場合は \-1 が返され、 .I errno に適切な値が設定される。 .\"O .SH ERRORS .SH エラー .TP .B EFAULT .\"O .I rlim .\"O points outside the accessible address space. .I rlim がアクセス可能なアドレス空間の外を指している。 .TP .B EINVAL .\"O .I resource .\"O is not valid; .\"O or, for .\"O .BR setrlimit (): .\"O .I rlim\->rlim_cur .\"O was greater than .\"O .IR rlim\->rlim_max . .I resource が有効でない。 または、 .BR setrlimit () で、 .I rlim\->rlim_cur が .I rlim\->rlim_max よりも大きかった。 .TP .B EPERM .\"O An unprivileged process tried to use .\"O .BR setrlimit () .\"O to .\"O increase a soft or hard limit above the current hard limit; the .\"O .B CAP_SYS_RESOURCE .\"O capability is required to do this. 特権のないプロセスが .BR setrlimit () を使用して ソフト・リミットまたはハード・リミットを 現在のハード・リミットより大きくしようと試みた。 これを行うためには .B CAP_SYS_RESOURCE ケーパビリティが必要である。 .\"O Or, the process tried to use .\"O .BR setrlimit () .\"O to increase .\"O the soft or hard .\"O .B RLIMIT_NOFILE .\"O limit above the current kernel .\"O maximum .\"O .RB ( NR_OPEN ). または特権のないプロセスが .BR setrlimit () を使用して ソフトまたはハード .B RLIMIT_NOFILE リミットを現在のカーネルの最大値 .RB ( NR_OPEN ) 以上に増加させようとした。 .\"O .SH CONFORMING TO .SH 準拠 SVr4, 4.3BSD, POSIX.1-2001. .\"O .B RLIMIT_MEMLOCK .\"O and .\"O .B RLIMIT_NPROC .\"O derive from BSD and are not specified in POSIX.1-2001; .\"O they are present on the BSDs and Linux, but on few other implementations. .B RLIMIT_MEMLOCK と .B RLIMIT_NPROC は BSD から派生し、POSIX.1-2001 には指定されていない。 これらは BSD 系と Linux に存在するが、他の実装は少ない。 .\"O .B RLIMIT_RSS .\"O derives from BSD and is not specified in POSIX.1-2001; .\"O it is nevertheless present on most implementations. .R RLIMIT_RSS は BSD から派生し、POSIX.1-2001 には指定されていない。 それにも関わらず多くの実装で存在する。 .\"O .BR RLIMIT_MSGQUEUE , .\"O .BR RLIMIT_NICE , .\"O .BR RLIMIT_RTPRIO , .\"O .BR RLIMIT_RTTIME , .\"O and .\"O .B RLIMIT_SIGPENDING .\"O are Linux-specific. .BR RLIMIT_MSGQUEUE , .BR RLIMIT_NICE , .BR RLIMIT_RTPRIO , .BR RLIMIT_RTTIME , .B RLIMIT_SIGPENDING は Linux 固有のものである。 .\"O .SH NOTES .SH 注意 .\"O A child process created via .\"O .BR fork (2) .\"O inherits its parent's resource limits. .\"O Resource limits are preserved across .\"O .BR execve (2). .BR fork (2) で作成された作成された子プロセスは、 親プロセスのリソース制限を継承する。 .BR execve (2) の前後でリソース制限は保存される。 .\"O One can set the resource limits of the shell using the built-in .\"O .IR ulimit .\"O command .\"O .RI ( limit .\"O in .\"O .BR csh (1)). .\"O The shell's resource limits are inherited by the processes that .\"O it creates to execute commands. シェルのリソース制限は、シェルの組み込みコマンドである .I ulimit .RB ( csh (1) では .I limit ) を使って設定することができる。 このシェルのリソース制限は、コマンドを実行してシェルが生成するプロセス に引き継がれる。 .\"O Ancient systems provided a .\"O .BR vlimit () .\"O function with a similar purpose to .\"O .BR setrlimit (). .\"O For backward compatibility, glibc also provides .\"O .BR vlimit (). .\"O All new applications should be written using .\"O .BR setrlimit (). 古いシステムでは、 .BR setrlimit () と同様の目的を持つ関数 .BR vlimit () が提供されていた。 後方互換性のため、glibc でも .BR vlimit () を提供している。 全ての新しいアプリケーションでは、 .BR setrlimit () を使用すべきである。 .\"O .SH BUGS .SH バグ .\"O In older Linux kernels, the .\"O .B SIGXCPU .\"O and .\"O .B SIGKILL .\"O signals delivered when a process encountered the soft and hard .\"O .B RLIMIT_CPU .\"O limits were delivered one (CPU) second later than they should have been. 以前の Linux カーネルでは、プロセスがソフトまたはハード .B RLIMIT_CPU リミットに達した場合に送られる .B SIGXCPU と .B SIGKILL シグナルが、本来送られるべき時点の 1 (CPU) 秒後に送られてしまう。 .\"O This was fixed in kernel 2.6.8. これはカーネル 2.6.8 で修正された。 .\"O In 2.6.x kernels before 2.6.17, a .\"O .B RLIMIT_CPU .\"O limit of 0 is wrongly treated as "no limit" (like .\"O .BR RLIM_INFINITY ). .\"O Since Linux 2.6.17, setting a limit of 0 does have an effect, .\"O but is actually treated as a limit of 1 second. 2.6.17 より前の 2.6.x カーネルでは、 .B RLIMIT_CPU リミットが 0 の場合、 .RB ( RLIM_INFINITY と同じように) 「制限なし」と間違って解釈されていた。 Linux 2.6.17 以降では、リミットを 0 に設定した場合にも 効果を持つようになっているが、実際にはリミットの値は 1 秒となる。 .\" see http://marc.theaimsgroup.com/?l=linux-kernel&m=114008066530167&w=2 .\"O A kernel bug means that .\"O .B RLIMIT_RTPRIO .\"O does not work in kernel 2.6.12; the problem is fixed in kernel 2.6.13. カーネル 2.6.12 には、 .B RLIMIT_RTPRIO が動作しないというバグがある。この問題はカーネル 2.6.13 で修正されている。 .\"O In kernel 2.6.12, there was an off-by-one mismatch .\"O between the priority ranges returned by .\"O .BR getpriority (2) .\"O and .\"O .BR RLIMIT_NICE . .\"O This had the effect that actual ceiling for the nice value .\"O was calculated as .\"O .IR "19\ \-\ rlim_cur" . .\"O This was fixed in kernel 2.6.13. .\"O .\" see http://marc.theaimsgroup.com/?l=linux-kernel&m=112256338703880&w=2 カーネル 2.6.12 では、 .BR getpriority (2) と .B RLIMIT_NICE が返す優先度の範囲が一つずれていた。このため、nice 値の実際の上限が .I "19\ \-\ rlim_cur" になってしまうという影響があった。これはカーネル 2.6.13 で修正された。 .\" 参考: http://marc.theaimsgroup.com/?l=linux-kernel&m=112256338703880&w=2 .\"O Kernels before 2.4.22 did not diagnose the error .\"O .B EINVAL .\"O for .\"O .BR setrlimit () .\"O when .\"O .I rlim\->rlim_cur .\"O was greater than .\"O .IR rlim\->rlim_max . 2.4.22 より前のカーネルでは、 .I rlim\->rlim_cur が .I rlim\->rlim_max より大きかった場合、 .BR setrlimit () での .B EINVAL エラーを検出できない。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR dup (2), .BR fcntl (2), .BR fork (2), .BR getrusage (2), .BR mlock (2), .BR mmap (2), .BR open (2), .BR quotactl (2), .BR sbrk (2), .BR shmctl (2), .BR sigqueue (2), .BR malloc (3), .BR ulimit (3), .BR core (5), .BR capabilities (7), .BR signal (7)