Bug 11403 - Failed to set controlling terminal
Summary: Failed to set controlling terminal
Status: WAITING
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 7.1
: P2 normal
Target Milestone: 7.2
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-19 13:01 IST by Egor
Modified: 2014-12-04 14:47 IST (History)
4 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 IST
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 IST
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;
}
Comment 2 Sergio Durigan Junior 2014-09-12 22:19:34 IST
Hi Egor and Jan, what is the status of this bug?
Comment 3 nikolay.koldunov 2014-12-04 14:47:50 IST
This is still valid at least on Solaris 11.2 and MacOS X 10.10 with GDB 7.7
Input is not redirected to a process being debugged but output from a process appears in a terminal specified