You shouldn't need to do this - just return a failure code from `wait()` and the machinery will take care of deciding when to print stdout.