SIGPIPEとは?
SIGPIPEは、プロセスが読み手のいなくなったpipeまたはsocketへ書き込もうとしたときにkernelが発生させるsignalです。そのデフォルト動作は書き込み側プロセスを終了させることで、これがdownstreamのコマンドが早く終了するとupstreamのコマンドをkillしうる理由です。動き続けたいプログラムは、代わりにこれを無視し、結果として生じる書き込みエラーを処理します。
なぜ重要か
CIのshell pipelineでのbroken-pipe失敗は、後続のコマンドが先のコマンドの書き込み完了前に終了したときのSIGPIPEであることが多いです。これを見分けられれば、一見不可解な早期終了を説明できます。
関連ガイド
What Is an Anonymous Pipe?An anonymous pipe is an unnamed in-memory channel that connects the output of one process to the input of ano…
What Is Signal Disposition?Signal disposition is how a process is set to respond to a given signal: run a handler, ignore it, or take th…
What Is Blocking IO?Blocking IO pauses the calling thread until an input or output operation finishes, so the thread cannot do ot…