Does Tcl do any internal input buffering that’s out of the script writers control? Will the following code possibly waste entropy (read more than 1 byte), and if so, how can I prevent it?
set stream [open "/dev/srandom"]
chan configure $stream -translation binary
set randomByte [chan read $stream 1]
Yes, tcl defaults to buffering and will waste enthropy (as much as a single
readcall will decide to hand over).I thought that you can prevent it with
But no,
-bufferinghas no effect on input queue (it’s not a single buffer internally).However,
does the trick, as I’ve seen from an experiment with
stdinunderstrace. It makes any input go inreads (syscall) of size 1 (an argument to TCLreaddoesn’t matter), so it would be extremely slow for normal use.