Runtime terminal setup for stdin
This issue should have a priority of something like "lower than very low."
If stdin is a terminal, the runtime currently puts the terminal into a pseudo-raw mode. See lang/stdfd.c:stdin_tty(). (It's not quite full raw mode since ISIG is still on; that would be very painful. :-)) In this mode, input characters are not automatically echoed, they're read one-at-a-time, and some special characters like ctrl-d are passed through the input rather than being interpreted, as an end of file for ctrl-d.
Is there a specific reason for doing this? There's nothing obvious in the git logs; it just appears fully formed.
Raw mode is needed for ANSITerm/Readline, and cooked mode is inappropriate if you're doing something involving a binary stream over a pseudo-tty or something (expect-like, maybe?). But it's a bit confusing if you just want to write a simple filter program.
Some discussion from irc:
(04:59:45 PM) mcguire: When it shows up:
(04:59:45 PM) mcguire: commit 416376cc10338ffc2b84a16ff4fb7c349c53aa50
(04:59:45 PM) mcguire: Author: sylvanc <[email protected]>
(04:59:45 PM) mcguire: Date: Mon Feb 2 12:34:14 2015 +0000
(05:00:13 PM) mcguire: "stdin support"
(05:30:23 AM) sylvanc: mcguire: that's to handle individual keypresses
(05:30:29 AM) sylvanc: rather than line-by-line input
Options are:
- Keep it the way it is and document it somewhere fairly visible. New users (Yo!) are going to be confused.
- Wait until the program uses ANSITerm/Readline to put the terminal into raw mode.
There's nothing pressing about this issue; I have a work-around (and the very tiny beginings of a Unix systems library).
While I am here, though, I did notice that the runtime is not restoring the terminal mode to raw after a suspend/resume. I'm not sure if that can be done in a SIGCONT handler (I've managed to avoid knowing that so far and might want to preserve my record.) or if it needs something more complex.
via @sylvanc stdfd.c code should probably be moved out of the runtime to pony userland.
via @jemc this functionality should be moved created as an option to turn on and off requiring ambient authority to change the TTY.
That is, it makes sense to require an authority token primitive derived from AmbientAuth (see NetAuth token for an example of this).