I don't think you can do that with a second command (a second executable). Why? The only information the "shell" which ran the first program gets about how the first program ended is the return status. And "crash" or "core dump" does not have a unique return status; matter of fact, nothing prevents me from writing a program that has an exit handler which returns a status = 0 at the end, even if it internally completely blew sky high.
What you can accomplish: catch the case when a program finishes with a non-zero exit status. Here is a snippet you could use in a shell script:
Code:
my_program -option argument1 argument2
if [ $? -ne 0 ] ; then
my_crash_cleaner ...
fi
I don't know a way to tell the usual shells to do this automatically. You could download the source code for sh (bash, ksh) or tcsh and modify it to automatically run a second program if the first one fails. Or you could write a smallish shell script which reads one line of input from the command line, executes it through a shell of your choice, and if the result is non-zero immediately runs the second program.
A better solution is to modify the program itself. Various programming languages have ways to implement exit handlers, which get run right before a program exits. In languages with exception handling (like Java or Python) you can combine that with putting an outer ring around the program, which catches and handles exceptions. That outer ring or exit handler could then do the functionality you desire from the second program.