Hi, one our user has reported an issue with wrong tty state after timed out read, when using utf-8 locale. The reproducer is:
cat >test.sh <<EOF #!/bin/ksh TMOUT=5 read EOF chmod +x test.sh ./test.sh Actual result (after letting read to time out) is tty does not echo any input until terminal is reset. Reporter provided a patch (attached) to fix this. ---------------------- Forwarded message: ---------------------- Description of problem: When a read command is run in a ksh script and is allowed to time out, ksh fails to restore the tty settings. Due to this the terminal stops echoing characters anymore until it is reset. This happens only when the locale is set to something with utf-8 encoding (en_US.UTF-8 for example) Version-Release number of selected component (if applicable): ksh-20100309-1.fc14.x86_64 How reproducible: Always Steps to Reproduce: <see above> Actual results: Script returns after 5 seconds and the terminal no longer echoes key strokes Expected results: Script returns after 5 seconds and the terminal behaves normally Additional info: When running in a UTF-8 locale, ksh employs viraw mode to accept input, due to which the tty is made into a raw terminal with echo disabled. It does not however, restore the terminal on exit, leading to a tty which does not echo keystrokes. Attached patch fixes this. ---------------- end of forwarded message ----------------------- Regards, Michal Hlavinka
The ed_viread method is used for reading when locale has an encoding that uses wide characters (utf8 for example). So we need to cook the raw'ed terminal before exit, otherwise we end up with a terminal that cannot echo. --- a/src/cmd/ksh93/sh/fault.c 2010-01-18 21:41:18.000000000 +0530 +++ b/src/cmd/ksh93/sh/fault.c 2010-03-10 21:23:56.000000000 +0530 @@ -614,7 +614,7 @@ void sh_done(void *ptr, register int sig sh_accend(); #endif /* SHOPT_ACCT */ #if SHOPT_VSH || SHOPT_ESH - if(sh_isoption(SH_EMACS)||sh_isoption(SH_VI)||sh_isoption(SH_GMACS)) + if(sh_isoption(SH_EMACS)||sh_isoption(SH_VI)||sh_isoption(SH_GMACS)||mbwide()) tty_cooked(-1); #endif #ifdef JOBS
_______________________________________________ ast-developers mailing list [email protected] https://mailman.research.att.com/mailman/listinfo/ast-developers
