exec システムコールとは?
exec システムコールは、呼び出し元プロセスに新しいプログラムを読み込み、そのメモリイメージを置き換えて、新しいプログラムをそのエントリポイントから開始します。プロセス ID や多くのディスクリプタは保持されますが、以前のコードとデータは破棄されます。通常は fork の直後に使われ、子が別のプログラムを実行できるようにします。
なぜ重要か
fork してから exec するペアは、shell が build 内のすべての外部コマンドを起動する方法です。exec がプロセス ID を保持することを知っていれば、なぜ exec の前に設定したリダイレクトが新しいプログラムへ引き継がれるのかが分かります。
関連ガイド
What Is the Fork System Call?The fork system call creates a new process by duplicating the calling one, producing a child that is a near-i…
What Is an Exit Status Code?An exit status code is the small integer a process returns when it finishes, where zero conventionally means…
What Is an Environment Block?An environment block is the set of name-value variables a process carries and passes to the children it launc…