|
|
|
@ -326,7 +326,9 @@ M.spawn_stdio = function(opts, fn_transform, fn_preprocess)
|
|
|
|
|
-- <C-c> err will be either EPIPE or ECANCELED
|
|
|
|
|
-- don't really need to do anything since the
|
|
|
|
|
-- processs will be killed anyways with os.exit()
|
|
|
|
|
if err then io.stderr:write("pipe:write Error: "..err) end
|
|
|
|
|
if err then
|
|
|
|
|
io.stderr:write(("pipe:write error: %s\n"):format(err))
|
|
|
|
|
end
|
|
|
|
|
if cb then cb(err) end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
@ -350,8 +352,16 @@ M.spawn_stdio = function(opts, fn_transform, fn_preprocess)
|
|
|
|
|
if stdout then
|
|
|
|
|
pipe_write(stdout, data, cb)
|
|
|
|
|
else
|
|
|
|
|
io.stdout:write(data)
|
|
|
|
|
cb(nil)
|
|
|
|
|
-- on success: rc=true, err=nil
|
|
|
|
|
-- on failure: rc=nil, err="Broken pipe"
|
|
|
|
|
-- cb with an err ends the process
|
|
|
|
|
local rc, err = io.stdout:write(data)
|
|
|
|
|
if not rc then
|
|
|
|
|
io.stderr:write(("io.stdout:write error: %s\n"):format(err))
|
|
|
|
|
cb(err or true)
|
|
|
|
|
else
|
|
|
|
|
cb(nil)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|