I'm debugging my program with gdb. I'm able to have a non-interactive debug using the -x
options.
gdb -x gdbinit ./myprogram
Content of gdbinit
file:
handle SIGINT pass nostop noprint
handle SIGQUIT pass nostop noprint
handle SIGUSR1 pass nostop noprint
handle SIGUSR2 pass nostop noprint
run
backtrace
quit
The four signals aren't handled by gdb because they are needed by my program to work properly.
The backtrace
command is useful to have a backtrace after a crash.
The quit
command make gdb exit after the program execution, even if it has crashed.
I want to exit automatically only if the program finishes successfully. In other cases, gdb should be available to analize backtraces and other things.
How can gdb exit ONLY if the program exits WITHOUT ERROR?