test: fix EPIPE race in spawn_closed_process_io

The just created stdin should not be closed by a child process before
writing to it, otherwise EPIPE happens.