I have a more general version that should work in all cases (a poll/waitpid loop). Doing a simple read may not receive all the data, and truncating does not protect against shorter inputs.