use blocks for popen so that ruby waits for child process to exit