Yet another attempt at a fix; logging improvements
My previous attempts weren't working: stdout was still occasionally lost. This redoes it to not require pseudoterminal allocation at all by instead using a pipe to send input to the remote process, and using an extra subprocess that blocks for input (which never comes), and kills the subprocess if it complete (i.e. because of an EOF). It seems to work: I haven't lost any output yet. This also adds some various logging improvements, showing connections/disconnections in the log as well as exit status (plus a reinterpretation of bash's 128+n as a N terminal signal).