Skip to main content
added 22 characters in body
Source Link

I'm using GDB to debug a program, and I want to direct its output to a different terminal than the one where GDB is running. Here's what I've been doing:

  1. Open a second terminal, check its device name using tty, and get something like /dev/pts/14.
  2. In my GDB session, I use the command tty /dev/pts/14 to set the output to that terminal.
  3. Then I issue the run command in GDB to start the program.

This setup does correctly direct the output to terminal 2, but the problem is that the first line on terminal 2 always says:

warning: GDB: Failed to set controlling terminal: Operation not permitted

I tried running GDB as root using sudo but encountered the same warning. Here's a simplified representation of my process:

# Terminal 2:
$ tty
/dev/pts/14

# Terminal 1:
$ gdb ./some-program
(gdb) tty /dev/pts/14
(gdb) run

Would anyone be able to explain what's causing this warning and how I could resolve or suppress it? What does GDB attempt to do when setting the controlling terminal, and why is it failing?

Note: Same things happens on a classic tty like /dev/tty3

I'm using GDB to debug a program, and I want to direct its output to a different terminal than the one where GDB is running. Here's what I've been doing:

  1. Open a second terminal, check its device name using tty, and get something like /dev/pts/14.
  2. In my GDB session, I use the command tty /dev/pts/14 to set the output to that terminal.
  3. Then I issue the run command in GDB to start the program.

This setup does correctly direct the output to terminal 2, but the problem is that the first line on terminal 2 always says:

warning: GDB: Failed to set controlling terminal: Operation not permitted

I tried running GDB as root using sudo but encountered the same warning. Here's a simplified representation of my process:

# Terminal 2:
$ tty
/dev/pts/14

# Terminal 1:
(gdb) tty /dev/pts/14
(gdb) run

Would anyone be able to explain what's causing this warning and how I could resolve or suppress it? What does GDB attempt to do when setting the controlling terminal, and why is it failing?

Note: Same things happens on a classic tty like /dev/tty3

I'm using GDB to debug a program, and I want to direct its output to a different terminal than the one where GDB is running. Here's what I've been doing:

  1. Open a second terminal, check its device name using tty, and get something like /dev/pts/14.
  2. In my GDB session, I use the command tty /dev/pts/14 to set the output to that terminal.
  3. Then I issue the run command in GDB to start the program.

This setup does correctly direct the output to terminal 2, but the problem is that the first line on terminal 2 always says:

warning: GDB: Failed to set controlling terminal: Operation not permitted

I tried running GDB as root using sudo but encountered the same warning. Here's a simplified representation of my process:

# Terminal 2:
$ tty
/dev/pts/14

# Terminal 1:
$ gdb ./some-program
(gdb) tty /dev/pts/14
(gdb) run

Would anyone be able to explain what's causing this warning and how I could resolve or suppress it? What does GDB attempt to do when setting the controlling terminal, and why is it failing?

Note: Same things happens on a classic tty like /dev/tty3

Source Link

How to suppress "Failed to set controlling terminal" warning in GDB when setting program to run on another terminal?

I'm using GDB to debug a program, and I want to direct its output to a different terminal than the one where GDB is running. Here's what I've been doing:

  1. Open a second terminal, check its device name using tty, and get something like /dev/pts/14.
  2. In my GDB session, I use the command tty /dev/pts/14 to set the output to that terminal.
  3. Then I issue the run command in GDB to start the program.

This setup does correctly direct the output to terminal 2, but the problem is that the first line on terminal 2 always says:

warning: GDB: Failed to set controlling terminal: Operation not permitted

I tried running GDB as root using sudo but encountered the same warning. Here's a simplified representation of my process:

# Terminal 2:
$ tty
/dev/pts/14

# Terminal 1:
(gdb) tty /dev/pts/14
(gdb) run

Would anyone be able to explain what's causing this warning and how I could resolve or suppress it? What does GDB attempt to do when setting the controlling terminal, and why is it failing?

Note: Same things happens on a classic tty like /dev/tty3