Date: Tue, 18 May 1999 13:31:24 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: djgpp-workers AT delorie DOT com Subject: termios and raw mode Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp-workers AT delorie DOT com While working on building and testing GDB 4.18, I noticed a problem in termios. Here's a fragment from the termios function that gets called instead of `_write' for file handles that are hooked by termios: if ((devmod & _DEV_CDEV) && (devmod & (_DEV_STDIN|_DEV_STDOUT))) { /* character device */ if (devmod & _DEV_RAW) *rv = __libc_termios_write_raw_tty (handle, buffer, count); else *rv = __libc_termios_write_cooked_tty (handle, buffer, count); return 1; } (`devmod' is the device information word returned by `_get_dev_info'). There is a similar fragment in the function that is called instead of `_read'. I think it is wrong to use the raw input/output simply because the device is in raw mode. The reason is that the device might be in raw mode because some other handle connected to it was switched to binary mode, but the application might still expect other handles connected to that device to work in the default cooked mode. The most striking case where the above code misfires is in a debugger. As soon as the debuggee switches its stdin to binary mode, the debugger's *output* will suddenly begin using binary mode too (e.g., NL isn't converted to CR-LF). I think this is wrong. A simple solution would be to replace this if clause: if (devmod & _DEV_RAW) with this: if ((devmod & _DEV_RAW) && (__file_handle_modes[handle] & O_BINARY)) Does anybody see any harm that would be done by this change? In particular, Mark, could you please see if Bash ever switches one of its handles to binary mode, and if so, will this somehow affect it?