process: close stdio after dup2'ing it

Thus allow passing the same file descriptor as the source of multiple
stdios.

fix #1074