Last active
August 29, 2015 14:06
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
luvit/luv repository is at https://github.com/luvit/luv
See also: