Tcl Source Code

View Ticket
Login
Ticket UUID: 666769
Title: TIP#160: Control TTY raw/cooked mode with [fconfigure]
Type: RFE Created on: 2003-01-12 19:48:27
Submitter: gwlester Assigned to: dkf
Subsystem: 27. Channel Types Severity:
Priority: 5 Medium Last modified: 2026-11-13 11:18:45
Status: Closed Closed by: serhiy.storchaka
Resolution: Fixed Closed on: 2026-11-13 11:18:43
Version: None
Description:
Configuring stdin to buffering none has no effect.

For example, run the following program.  Typing an "X" should cause it to complete, however a "X<CR>" 
must be typed.  This is true under both Linux and Windows NT.

fconfigure stdin -blocking yes -buffering none -translation {binary binary}
puts [fconfigure stdin]
set ch [read stdin 1]
puts stdout "\n\tYou typed a '$ch'"
flush stdout
User Comments:
vincentdarley added on 2003-01-14 05:12:56:
Logged In: YES 
user_id=32170

Not a filesystem problem, but a channel system one I assume.

hobbs added on 2003-01-14 05:17:53:
Logged In: YES 
user_id=72656

I do not believe this is a Tcl problem at all, but rather the fact 
that you can't control a tty in this way.  On unix you would 
have to call stty with special settings, or use Expect.  There 
are examples of this on the net.

dkf added on 2003-01-16 13:03:50:
Logged In: YES 
user_id=79902

On any UNIX platform, this will only work if you change the 
channel driver from its default "cooked" mode to "raw". The 
cooked mode allows for basic line editing in simple apps (like 
cat!) so it is a good thing, but for some cases that's not 
sufficient.  Tcl does not currently support changing the TTY 
mode this way, though I would personally be very 
sympathetic to anyone who wants to add the feature.

I presume Windows has something similar, though I don't 
know the platform nearly well enough to be able to sensibly 
comment.

Transforming this to a FRQ

nobody added on 2003-01-16 13:54:12:
Logged In: NO 

Based on Don's and Jeff's comments, this should at least be 
changed to a documentation bug.

In other words, the documentation should explictly state 
that stdin/stdout/stderr are not effect by certain aspects 
of fconfigure.

If this is also true of other ttys, it should also be 
explictity stated.

dkf added on 2003-10-17 17:47:55:
Logged In: YES 
user_id=79902

See TIP#160 http://purl.org/tcl/tip/160

serhiy.storchaka added on 2026-11-13 11:18:45:

Implemented in Tcl 9.0 by TIP 160: fconfigure stdin -inputmode raw (and normal, password, reset) switches the terminal mode of serial channels on Unix and of console channels on Windows.