Fix some fd issues when running subprocesses.