wait システムコールとは?
wait システムコールは、親プロセスがいずれかの子プロセスの状態が変化するまで実行を中断し、その子の終了ステータスを収集する仕組みです。ステータスを読み取ることで子を回収 (reap) し、プロセステーブルから取り除くため、ゾンビとして残りません。バリアントを使えば、親は特定の子を待つことも、ブロックせずに確認することもできます。
なぜ重要か
shell やスーパーバイザは、各ステップの終了コードを知るためと、終了した子を後始末するために wait を使います。これを省くと、長時間稼働する runner 上でゾンビプロセスが発生します。
関連ガイド
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 Reaping a Child Process?Reaping is when a parent calls a wait operation to read a finished child exit status, freeing the kernel slot…
What Is SIGCHLD?SIGCHLD is the signal the kernel sends a parent process when one of its child processes stops or terminates,…