-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uv.spawn example code in docs is broken #606
Comments
Additional notes, I also cannot get anything useful from the code snippet provided in uv.pipe local uv = require("luv")
local fds = uv.pipe({nonblock=true}, {nonblock=true})
local read_pipe = uv.new_pipe()
read_pipe:open(fds.read)
local write_pipe = uv.new_pipe()
write_pipe:open(fds.write)
write_pipe:write("hello")
read_pipe:read_start(function(err, chunk)
assert(not err, err)
print(chunk)
end) The above code does not fail, it just does nothing. I never see anything print from the I have verified that |
I believe the biggest problem you're running into is that you don't have a call to The most up-to-date examples would be from our tests. Here's a relevant Lines 96 to 138 in 9f80386
Here's a full adapted version that will work outside our test setup: local uv = require('luv')
-- set this depending on your OS
local isWindows = false
local stdin = uv.new_pipe(false)
local stdout = uv.new_pipe(false)
local input = "Hello World"
local cmd, args, expectedOutput
if isWindows then
cmd = "cmd.exe"
args = {"/c", "set /p output=&call echo %output%"}
expectedOutput = input .. "\r\n"
else
cmd = "cat"
args = {"-"}
expectedOutput = input
end
local handle, pid
handle, pid = uv.spawn(cmd, {
args = args,
stdio = {stdin, stdout},
}, function (code, signal)
print("exit", code, signal)
uv.close(handle)
end)
print(handle, pid)
uv.read_start(stdout, function (err, chunk)
print("stdout", chunk)
assert(not err, err)
assert(chunk == expectedOutput)
uv.close(stdout)
end)
uv.write(stdin, input)
uv.shutdown(stdin, function ()
uv.close(stdin)
end)
uv.run() |
Ahh it was Thank you! |
Hello! I am looking into trying to use luv's implementation of
spawn
but the provided sample code is unusable. When it is run (I've attached the example I am using), I receive the following errorLine 41
Removing this line avoids this error but another is thrown
New line 41
I can't quite pin my finger on what the error is, hoping someone can get me pointed in the right direction.
Useful info
I am having other issues with spawn as well (such as not being able to get stdout from it, it leaving defunct processes, etc) but I think this is due to my misunderstanding of how I am supposed to be using it.
Thanks!
The text was updated successfully, but these errors were encountered: