wait for subprocess to finish