This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH] Honor --tty and tty command on windows
- From: Christopher Faylor <cgf at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Fri, 13 Sep 2002 23:27:35 -0400
- Subject: [PATCH] Honor --tty and tty command on windows
Someday, I'm going to merge all of this with the similar code in
fork-child...
cgf
2002-09-13 Christopher Faylor <cgf@redhat.com>
* win32-nat.c (child_create_inferior): Honor 'tty' command.
Index: win32-nat.c
===================================================================
RCS file: /cvs/uberbaum/gdb/win32-nat.c,v
retrieving revision 1.61
diff -u -p -r1.61 win32-nat.c
--- win32-nat.c 26 Aug 2002 19:18:33 -0000 1.61
+++ win32-nat.c 14 Sep 2002 03:26:10 -0000
@@ -1461,6 +1461,8 @@ child_create_inferior (char *exec_file,
char *toexec;
char shell[MAX_PATH + 1]; /* Path to shell */
const char *sh;
+ int tty;
+ int ostdin, ostdout, ostderr;
if (!exec_file)
error ("No executable specified, use `target exec'.\n");
@@ -1573,6 +1575,29 @@ child_create_inferior (char *exec_file,
*temp = 0;
}
+ if (!inferior_io_terminal)
+ tty = ostdin = ostdout = ostderr = -1;
+ else
+ {
+ tty = open (inferior_io_terminal, O_RDWR | O_NOCTTY);
+ if (tty < 0)
+ {
+ print_sys_errmsg (inferior_io_terminal, errno);
+ ostdin = ostdout = ostderr = -1;
+ }
+ else
+ {
+ ostdin = dup (0);
+ ostdout = dup (1);
+ ostderr = dup (2);
+ dup2 (tty, 0);
+ dup2 (tty, 1);
+ dup2 (tty, 2);
+ }
+ }
+
+
+
ret = CreateProcess (0,
args, /* command line */
NULL, /* Security */
@@ -1583,6 +1608,17 @@ child_create_inferior (char *exec_file,
NULL, /* current directory */
&si,
&pi);
+ if (tty >= 0)
+ {
+ close (tty);
+ dup2 (ostdin, 0);
+ dup2 (ostdout, 1);
+ dup2 (ostderr, 2);
+ close (ostdin);
+ close (ostdout);
+ close (ostderr);
+ }
+
if (!ret)
error ("Error creating process %s, (error %d)\n", exec_file, GetLastError ());