Break out stty settings handling into a utility.

So we can reuse it for python REPL running, eventually.