concurrency fix: make sure forked process finished before reading output from it