I’m debugging a shell script on OSX with mysterious segfault in the middle. The command in question does not segfault if executed outside of script.
So i need to somehow run all programs in script with GDB attached so i can debug this segfault. Is it possible to configure GDB so it will run the program and quit if program terminated correctly? I have tried the following code:
echo file ifconfig > gdbcfg
echo run >> gdbcfg
echo quit >> gdbcfg
gdb -x gdbcfg
But this is not working since GDB tries to execute quit command before application terminates normally :(. Is it possible to somehow instruct GDB to wait for application normal termination and quit after that?
Maybe my approach is too comples and it’s just some GDB flag like “load and run this application, quit if all is ok”?
Why not just make the process to dump a core file and analyze it later with gdb? I mean ulimit -c unlimited and then (after the core is dumped) gdb ./process core?