On Oct 16, 2018 at 9:40 AM Karel Zak wrote: > On Tue, Oct 16, 2018 at 08:41:49AM +0200, Lubomir Rintel wrote: >> Seems like zero lflags do the job just fine on a Linux VT. Reset it to >> canonical mode before running login. > > What about Del/Backspace keys when user is typing login name? :-) It could be easy without Backspace support. Just read the characters. But we have to implement Backspace. When you leave canonical mode, then agetty code has to handle Backspace. Hopefully, agetty doesn't support arrows and Delete (forward delete), so we don't have to implement advanced parts of line editing. My experiments show two possibilities. I am not sure, what is better, but 1 seems to be more straightforward. 1) c_lflag &= ~(ICANON | ECHO) This falls back to a no echo mode. Program has to handle echo and buffer parsing. Program has to handle backspace. The implementation seems to be straightforward. Downside: Remote logins can experience delays when getting echo. 2) c_lflag &= ~(ICANON) Non-canonical mode with echo seems to be usable as well. The terminal itself does the echo, program does the input parsing. Program has to handle Backspace. Echo will be immediate even with slow remote logins, but Backspace has to be handled remotely. The second implementation has a problem: The Linux console input and output are out of sync in the time of agetty. Input returns 0x7f after pressing backspace, but output does back step (not back space) after sending 0x08. I don't know the fix yet. Even with a proper configuration of erase character, terminal in a non-canonical mode cannot do a back space. At the best, it will do back step. So, in the echo mode, program has to handle Backspace not only for the input, but also for the output: Print a space to erase the deleted character and then one back step again. This approach is vulnerable to race: New letter is typed before processing of backspace is not finished yet. But if I am correct, this race will not affect the result on the screen. -- Best Regards / S pozdravem, Stanislav Brabec software developer --------------------------------------------------------------------- SUSE LINUX, s. r. o. e-mail: sbrabec@xxxxxxxx Křižíkova 148/34 (Corso IIa) tel: +49 911 7405384547 186 00 Praha 8-Karlín fax: +420 284 084 001 Czech Republic http://www.suse.cz/ PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76