Bug 11403 - Failed to set controlling terminal
: Failed to set controlling terminal
Status: WAITING
Product: gdb
Classification: Unclassified
Component: gdb
: 7.1
: P2 normal
: 7.2
Assigned To: Not yet assigned to anyone
:
:
:
:
  Show dependency treegraph
 
Reported: 2010-03-19 13:01 UTC by Egor
Modified: 2010-08-15 20:02 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Egor 2010-03-19 13:01:14 UTC
On OpenSolaris b111, gdb 7.0.1 and 7.0
I try to debug a program with different tty:
gdb -tty /dev/pts/6 a.out
when I start the program I get:
warning: GDB: Failed to set controlling terminal: Inappropriate ioctl for device
in the output.

With gdb 6.8 and prior I have not seen this.
Comment 1 Jan Kratochvil 2010-08-15 20:02:04 UTC
This issue started with:
[RFA] Fix GDB's handling of the inferior controlling terminal.
http://sourceware.org/ml/gdb-patches/2008-03/msg00103.html
(as reported by Alan Matsuoka)

The changed fixed other problems described there.

Either you should ignore the warning as it has the same functionality as gdb-6.x
before the change above.  For example signals do not work in that TTY, though. 
If you want to benefit from the fully dedicated TTY to the inferior process you
should run first the helper pasted below.

(One can discuss whether to call TIOCSCTTY with 0 (current) or 1.  IMO the
current value is right, 1 would not make it much easier and it would just
require root privileges plus make it whole less clear.)

I would suggest for GDB to make some notice to such a helper in the warning.
Thanks for the bugreport, is it OK this way?

------------------------------------------------------------------------------

/* tty;exec disowntty  */
#include <sys/ioctl.h>
#include <unistd.h>
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include <signal.h>
static void
end (const char *msg)
{
  perror (msg);
  for (;;)
    pause ();
}
int
main (void)
{
  void (*orig) (int signo);
  setbuf (stdout, NULL);
  orig = signal (SIGHUP, SIG_IGN);
  if (orig != SIG_DFL)
    end ("signal (SIGHUP)");
  /* Verify we are the sole owner of the tty.  */
  if (ioctl (STDIN_FILENO, TIOCSCTTY, 0) != 0)
    end ("TIOCSCTTY");
  /* Disown the tty.  */
  if (ioctl (STDIN_FILENO, TIOCNOTTY) != 0)
    end ("TIOCNOTTY");
  end ("OK, disowned");
  return 1;
}