« Previous | Next » 

Revision 3023170f

ID3023170fe8d7f8c0de823a858c3ef229fa2a427b
Parent 781b2b2b
Child 01ca31ae

Added by Iustin Pop almost 15 years ago

Fix AskUser to not die on extra input

Currently, AskUser dies with -ESPIPE if the user gives more than one
character plus newline. This is because the python library, while
returning only two chars from the readline(2) call, will cache the rest
of the input, and when we do a write, it will try to seek back to just
after the last returned char. This fails on /dev/tty, so an exception is
raised. However, then opening the file descriptor in O_APPEND mode,
python will not issue such seeks, thereby fixing this problem.

The other alternative, opening in unbuffered mode, is not as good, since
then python will issue one-byte reads at a time, but the tty will read
the entire line, so at the next readline call, whatever remained in the
descriptor buffer is returned from the kernel to python, and the user
doesn't get a chance to enter something at all.

Reviewed-by: imsnah

Files

  • added
  • modified
  • copied
  • renamed
  • deleted

View differences