Unix-system-calls-fork
提供:Dev Guides
[top]#
|http://www.google.com/[Google] | a|
Web | This Site |
選択した読書 Copyright©2014 by finddevguides |
[cols=",,,,,,,",] |
| | Home | | References | | Discussion Forums | | About TP
[width="100%",cols="100%",] |
a| == fork()-Unix、Linuxシステムコール
[[File:]] image :http://www.finddevguides.com/images/next.gif [next] image:http://www.finddevguides.com/add- this.gif [AddThisソーシャルブックマークボタン]
広告
NAME
fork-子プロセスを作成します
概要
#include <sys/types.h> #include <unistd.h> pid_t fork(void); |
説明
*fork* ()は、PIDとPPIDのみが異なり、リソース使用率が0に設定されているという点で、親プロセスとは異なる子プロセスを作成します。 ファイルロックと保留中のシグナルは継承されません。
Linuxでは、コピーオンライトページを使用して fork ()が実装されているため、発生する唯一のペナルティは、親のページテーブルを複製し、子の一意のタスク構造を作成するために必要な時間とメモリです。
返り値
成功すると、子プロセスのPIDが親の実行スレッドに返され、0が子の実行スレッドに返されます。 失敗すると、-1が親のコンテキストで返され、子プロセスは作成されず、_errno_が適切に設定されます。
エラー
Error Code | Description |
---|---|
EAGAIN | fork() cannot allocate sufficient memory to copy the parent’s page tables and allocate a task structure for the child. |
*EAGAIN * | It was not possible to create a new process because the caller’s* RLIMIT_NPROC resource limit was encountered. To exceed this limit, the process must have either the CAP_SYS_ADMIN or the CAP_SYS_RESOURCE* capability. |
ENOMEM | fork() failed to allocate the necessary kernel structures because memory is tight. |
準拠
SVr4、4.3BSD、POSIX.1-2001。
関連項目
- clone(2)
- execve(2)
- setrlimit(2)
- unshare(2)
- vfork(2)
- http://www.finddevguides.com/unix_system_calls/wait [待機(2)]
[[File:]] image :http://www.finddevguides.com/images/next.gif [next] [[File:]]
広告
|
[cols="^",] |
|Advertisements