inferior can't get terminal size with TIOCGWINSZ

Hi,

I've noticed that an inferior running in the same terminal as lldb
doesn't seem to be able to get the terminal size with TIOCGWINSZ. Is
this expected? I don't have the same problem with gdb.

Test case is below, running on Darwin 14 over an SSH connection.

Thanks,
Jay.

$ cat winsz.c
#include <stdio.h>
#include <sys/ioctl.h>
#include <termios.h>
#include <unistd.h>

int main() {
  struct winsize size;
  int tty = isatty(0);
  int ret = ioctl(0, TIOCGWINSZ, &size);
  printf("tty %d ret %d row %d col %d\n", tty, ret, size.ws_row, size.ws_col);
}
$ clang -o winsz winsz.c
$ ./winsz
tty 1 ret 0 row 24 col 80
$ lldb winsz
(lldb) target create "winsz"
Current executable set to 'winsz' (x86_64).
(lldb) run
Process 43730 launched: '/Users/jay/winsz' (x86_64)
tty 1 ret 0 row 0 col 0
Process 43730 exited with status = 0 (0x00000000)
(lldb)

Yes, lldb doesn't share a terminal with the target the way gdb does (swapping control back and forth when the target stops & restarts.) Instead it creates pty's for the target, and uses those. If you need to debug a command-line program that's making use of the terminal, you should launch it in a terminal and attach to it. On darwin, you can use the -tty option to "process launch" to get lldb to do this for you. This may not work in an ssh session, however.

Jim

Thanks for the info. -tty doesn't seem to work in my ssh session.
Maybe I can do something clever with "screen" multiplexing.

Thanks,
Jay.