1

My SSH session was terminated abruptly and gdb was running. When I try to attach gdb again to the same process, I get:

ptrace: Operation not permitted.

The ttys:

[root@xxx ~]# who
root     pts/0        2017-11-27 03:57 (10.193.26.12)
root     pts/1        2017-11-27 04:40 (10.193.26.12)

Question: Which signal should I send to GDB for it to quit gracefully? Are there other ways to solve it?

Mindaugas Bernatavičius
  • 3,757
  • 4
  • 31
  • 58

1 Answers1

0

kill -HUP $gdbpid did the trick for me.

This also kills the inferior when it was invoked by the victim GDB. However, I do not know whether it also kills the inferior when GDB has been attached to the inferior.

If the parent shell of GDB is still running, then you can attempt to close the pseudo terminal. I usually do it like this:

echo > /dev/pts/0

This forces the SSH parent process to exchange data with the peer. But since the network connection it is gone (as in "the terminal has hung up"), it goes through its shutdown procedure, which includes sending SIGHUP to the process group. The net effect is the same.

j6t
  • 9,150
  • 1
  • 15
  • 35