Following code gets stuck(which I think is blocking I/O) many times (works some time).
def static executeCurlCommand(URL){ def url = \"curl \" + URL;
The first approach fills a buffer up and then blocks waiting for more room to write output to.
The second approach streams output from the buffer via a separate thread as the process is running, so the process doesn't block.