Close the read end of the error pipe after the build
Ensure we always wait on the child in safe_system
update: restore previous state when interrupted