Skip to content

Commit

Permalink
Fix multiprocess mode pipes to use io.write() instead of opening a ne…
Browse files Browse the repository at this point in the history
…w file descriptor on /dev/stdout and /dev/stderr
  • Loading branch information
jdrouhard authored and ibhagwan committed Dec 13, 2021
1 parent 4a013fd commit 317aafa
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lua/fzf-lua/libuv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,12 @@ M.spawn_stdio = function(opts, fn_transform, fn_preprocess)
end)
end

stderr = pipe_open(opts.stderr or "/dev/stderr")

-- /dev/stdout seems to create issues on MacOS (#248, #251)
-- do not use a pipe unless use specifically requests it
-- instead we use 'io.write'
stdout = pipe_open(opts.stdout)
if opts.stderr then
stderr = pipe_open(opts.stderr)
end
if opts.stdout then
stdout = pipe_open(opts.stdout)
end

local on_finish = opts.on_finish or
function(code)
Expand All @@ -351,14 +351,19 @@ M.spawn_stdio = function(opts, fn_transform, fn_preprocess)
if stdout then
pipe_write(stdout, data, cb)
else
io.write(data)
io.stdout:write(data)
cb(nil)
end
end

local on_err = opts.on_err or
function(data)
pipe_write(stderr, data)
if stderr then
pipe_write(stderr, data)
else
io.stderr:write(data)
cb(nil)
end
end

return M.spawn({
Expand Down

0 comments on commit 317aafa

Please sign in to comment.