Improve error handling for subprocesses.