hi!

Please review: https://code.illumos.org/c/illumos-gate/+/3403

1. (attempt to) reset terminal early in order to get more consistent terminal output
2. drain input from random bytes (happens with some systems).

thanks,
toomas