Add spec for io inheritance

Also add a spec helper to capture process' own stdout and stderr.