cli: Fix FTBFS on kfreebsd

Update terminal handling borrowed from busybox. Do not modify any input
mode bits. Do not clear the TOSTOP mode flag.

Do the same for the example program.

Signed-off-by: Mike Miller <mtmiller@ieee.org>