fix fd leak

close both sides of pipe opened with os.pipe()