Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to handle SIGTSTP with GDB

📅 2015-May-11 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ gdb, signal, sigtstp ⬩ 📚 Archive

Problem

I use 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:

(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)

Solution

To view the signals handled by GDB and how they are handled:

(gdb) info signals
(gdb) info signal SIGTSTP
Signal        Stop  Print   Pass to program Description
SIGTSTP       Yes   Yes Yes     Stopped (user)
(gdb) handle SIGTSTP nopass

Tried with: GDB 7.7.1 and Ubuntu 14.04


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧