Ctrl+Z regularly at the shell to temporarily stop a program and then continue its running using the
fg command. However, doing the same in GDB does not work as expected:
- I press
Ctrl+Z. GDB catches it and prints out a message saying
SIGTSTPhas been received.
continuedoes not continue the execution of the program. The program keeps getting stopped again and prints this message:
(gdb) c Continuing. Program received signal SIGTSTP, Stopped (user). [Switching to Thread 0x7fffe7e28700 (LWP 1492)] 0x00007ffff5b5112d in poll () at ../sysdeps/unix/syscall-template.S:81 81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
To view the signals handled by GDB and how they are handled:
(gdb) info signals
- To view how a specific signal, say
(gdb) info signal SIGTSTP Signal Stop Print Pass to program Description SIGTSTP Yes Yes Yes Stopped (user)
- We can see that by default, this signal is passed to the program. By not passing it to the program, just like what a shell does, our problem is solved. To do this, use the
(gdb) handle SIGTSTP nopass
continuenow and the program continues from where it was stopped.
Tried with: GDB 7.7.1 and Ubuntu 14.04