Tcl version: 8.4+
OS: Linux Red Hat 4, 5
Maybe, it is a Linux bug, but it appeared in Tcl's stdin handling. I got the problem in C, but I created a Tcl script that fails the same way.
If you execute a certain command though system()/exec which fails, stdin stream does not provide any more input except already buffered in C code. My Tcl script is more that 8K long because I initially got the problem on the very next byte after 8K, but attached test fails a bit earlier.
Important: file must be redirected to stdin:
> tclsh <xxx.tcl
Read(0) just returns 0 as if it is the end of pipe/socket. If you specify file name as an argument, the script works.
I cannot classify the problem. Just weird. Stdin stays open, /proc/pid/fd shows it, but 0 handle is damaged. Fork/clone is doing something bad to to the parent's stdin.
Any help is appreciated. I cannot depend on any developer who can call system() and break stdin. Yes, I know that such redirection seem to make no sense, but it does; it is just a simplified version.