Add explicit close on pipes
Give curl input from stdin, something is hanging it
Properly close stdin on all popen calls

Oh ruby, wherefore art thou docs?