Search code examples
linuxterminalgdbgnutty

gdb set inferior-tty warning: GDB: Failed to set controlling terminal: Operation not permitted


I am trying to debug a program using (gdb) , this program has a command that let you route the Input/Output of the program been debug into other spawned terminal of the same system (set inferior-tty <myTty> ). I open a new Terminal (/dev/pts/22) and set this option. And start debugging the program.

Straight after I get this message in the second terminal GDB: Failed to set controlling terminal: Operation not permitted

The Input/Output seems to be redirected to this Second Terminal but it missbehaves ending up the command not achieving its functionality.

Terminal1: https://asciinema.org/a/obOQEjLR7lGxLdcje1VQvEHiL Terminal2: https://asciinema.org/a/AEjCyQFqSdiqXNBSRrVW2uuMa


Solution

  • In your second terminal, run something like:

    tty && tail -f /dev/null
    

    then use the output of the tty command with GDB just as you are currently doing.

    Without the tail command your existing shell and GDB are both fighting for control of the terminal.