Quickie port to FreeBSD 9.1. Modern BSDs have termios and poll.