state poll: write 1 byte to the socket on close

It may take a few seconds for select() to notice the peer end of the
socket is closed. Instead write a byte with a magic value to indicate
close.
Close stdin in the forked process

stdout/stderr are shared with the parent.