[server] Properly resume stdin, register eof handler at toplevel

Issue #242