IO.popen behaving strangely within SU
-
Hi all -
I am trying to run a subprocess from a shell command using
IO.popen
(have also triedKernel#system
with identical results), and I'm getting odd behavior. Here's my code:curl = "curl " curl += "--cookie \"JSESSIONID=#{@sessionid}\" " curl += "-H \"Content-type;application/octet-stream\" " curl += "-X POST " curl += "-o \"#{responseFile}\" " curl += "--data-binary \"@#{filename}\" " curl += "\"#{url}\"" puts "command; #{curl}" IO.popen(curl, "r") { |out| out.readlines } # Script never makes it to here
It's a streaming file upload using
curl
. Curl starts uploading, sends about 100kb, which is received by my server, and suddenly the stream ends ("unexpected end of stream error" on the server-side). Curl keeps running endlessly, sending zero data after that. Since I'm blocking withreadlines
, SU is forever frozen from then on...I have tried this same code in a standalone script as well as running the command directly from a shell, and both work fine.
Anyone encountered this before? SU doesn't seem to like subprocesses...
EDIT: I should note this is on OSX.
Advertisement