summaryrefslogtreecommitdiff
path: root/gdb/ser-go32.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2000-03-15 11:10:52 +0000
committerEli Zaretskii <eliz@gnu.org>2000-03-15 11:10:52 +0000
commit2dba7270fe003175274cf9a735b88d7b1cff29fb (patch)
tree913a0c4092c2ff8752c6995dc137dcd6432478d9 /gdb/ser-go32.c
parent73d0797dc6a0e3095d69cc21804f8136cfaa9846 (diff)
downloadgdb-2dba7270fe003175274cf9a735b88d7b1cff29fb.tar.gz
* ser-go32.c (dos_get_tty_state): Fail if the (fake) handle was
not opened by dos_open, but let the 3 standard handles go through unharmed.
Diffstat (limited to 'gdb/ser-go32.c')
-rw-r--r--gdb/ser-go32.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/gdb/ser-go32.c b/gdb/ser-go32.c
index 0474000e61a..1d5eea23449 100644
--- a/gdb/ser-go32.c
+++ b/gdb/ser-go32.c
@@ -488,6 +488,10 @@ dos_open (scb, name)
return -1;
}
+ /* FIXME: this is a Bad Idea (tm)! One should *never* invent file
+ handles, since they might be already used by other files/devices.
+ The Right Way to do this is to create a real handle by dup()'ing
+ some existing one. */
fd = name[3] - '1';
port = &ports[fd];
if (port->refcnt++ > 0)
@@ -650,6 +654,19 @@ dos_get_tty_state (scb)
struct dos_ttystate *port = &ports[scb->fd];
struct dos_ttystate *state;
+ /* Are they asking about a port we opened? */
+ if (port->refcnt <= 0)
+ {
+ /* We've never heard about this port. We should fail this call,
+ unless they are asking about one of the 3 standard handles,
+ in which case we pretend the handle was open by us if it is
+ connected to a terminal device. This is beacuse Unix
+ terminals use the serial interface, so GDB expects the
+ standard handles to go through here. */
+ if (scb->fd >= 3 || !isatty (scb->fd))
+ return NULL;
+ }
+
state = (struct dos_ttystate *) xmalloc (sizeof *state);
*state = *port;
return (serial_ttystate) state;