title: How to detect why a process terminated programatically in Linux
body: <p>Processes are terminated for one of three reasons: they've reached end of execution (nominal case), they contain an uncaught exception (synchronous crash), or they've received some signal that they are not handling (asynchronous crash). Within the design of a program, we can instrument ways of at least detecting each of these (e.g., catch statements, signal handlers, etc.).</p>
  
  <p>Suppose I wanted to design a program that can monitor another program's execution in Linux. I can easily tell if the program terminated by noticing its PID disappearing from <code>/proc</code>, but I won't know why. Is there a way to observe the target program to determine the cause of termination?</p>