Skip to content

Instantly share code, notes, and snippets.

@hnakamur
Last active August 29, 2015 14:06
Show Gist options
  • Save hnakamur/d503915badd15e7dd0cc to your computer and use it in GitHub Desktop.
Save hnakamur/d503915badd15e7dd0cc to your computer and use it in GitHub Desktop.
an example luvit/luv spawn a process and connect stdout to stdout or file
local uv = require("luv")
local options = {
stdio = {
nil,
1,
nil
}
}
local child, pid = uv.spawn("ls", {"-l"}, options)
function child:onexit(code, signal)
print("EXIT", "code", code, "signal", signal)
uv.close(child)
end
repeat
until uv.run('once') == 0
local uv = require "luv"
local fd = uv.fs_open('ls_output.txt', 'w', tonumber('644', 8))
local options = {
stdio = {
0,
fd,
2
}
}
local child, pid = uv.spawn("ls", {"-l"}, options)
uv.fs_close(fd)
local uv = require "luv"
local options = {
stdio = {
nil,
1,
nil
}
}
local child, pid = uv.spawn("ls", {"-l"}, options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment