code duplication:
lines 27-29, 31-33

Consider remove.
Can it be connected to signal handling cause then, may be we indeed need conditions for various exceptions (abnormal termination, stop signal sent by user, immediate abort sent by user,...)?  

The same is due for other executable files.