終了ステータスコードとは?
終了ステータスコードとは、プロセスが終了時に親プロセスへ報告する数値で、そのプロセスが成功したかどうかを要約したものです。慣例により、ゼロは成功を意味し、ゼロ以外の値は特定の種類の失敗を示します。親プロセスはこのコードを wait 操作を通じて取得し、シグナルによって終了させられたプロセスは区別可能なステータスを返します。
なぜ重要か
CI はステップが成功したか失敗したかを、ほぼ完全にその終了ステータスコードで判断します。そのため、ゼロ以外のコードを握りつぶすスクリプトは本当の失敗を隠してしまいます。終了コードを正しく扱うことは、信頼できる pipeline の成功・失敗判定にとって基本です。
関連ガイド
What Is the Wait System Call?The wait system call lets a parent process pause until a child terminates and then read the child exit status…
What Is the Exec System Call?The exec system call replaces the program running in the current process with a new one, keeping the same pro…
What Is a Background Process?A background process runs without holding the foreground of a shell, letting the shell accept other commands…