Permalink
Browse files

luv_process: upgrade to libuv 0.8

libuv started using an array of uv_stdio_container_t objects instead of
the explicit stderr/stdin/stdout object. Update to this new API to get
the stdout moving again in test-process.lua.

TODO: test-process.lua is still hanging, something is still holding a
ref.
  • Loading branch information...
1 parent aa4cc47 commit 870fbbc3dcaa2a340c8dcaeccd428198fce1cdf4 @philips philips committed with Brandon Philips Aug 7, 2012
Showing with 31 additions and 8 deletions.
  1. +30 −8 src/luv_process.c
  2. +1 −0 tests/test-process.lua
View
38 src/luv_process.c
@@ -48,23 +48,50 @@ int luv_getpid(lua_State* L){
/* Initializes uv_process_t and starts the process. */
int luv_spawn(lua_State* L) {
- uv_pipe_t* stdin_stream = (uv_pipe_t*)luv_checkudata(L, 1, "pipe");
- uv_pipe_t* stdout_stream = (uv_pipe_t*)luv_checkudata(L, 2, "pipe");
- uv_pipe_t* stderr_stream = (uv_pipe_t*)luv_checkudata(L, 3, "pipe");
+ uv_stream_t* stdin_stream = (uv_stream_t*)luv_checkudata(L, 1, "pipe");
+ uv_stream_t* stdout_stream = (uv_stream_t*)luv_checkudata(L, 2, "pipe");
+ uv_stream_t* stderr_stream = (uv_stream_t*)luv_checkudata(L, 3, "pipe");
const char* command = luaL_checkstring(L, 4);
size_t argc;
char** args;
int i;
char* cwd;
char** env;
uv_process_options_t options;
+ uv_stdio_container_t stdio[3];
uv_process_t* handle;
int r;
luaL_checktype(L, 5, LUA_TTABLE); /* args */
luaL_checktype(L, 6, LUA_TTABLE); /* options */
memset(&options, 0, sizeof(uv_process_options_t));
+ memset(stdio, 0, sizeof(stdio));
+
+ options.stdio = stdio;
+ options.stdio_count = 3;
+
+ /*
+ TODO: Handle ignoring stdio
+ options.stdio[0].flags = UV_IGNORE;
+ options.stdio[1].flags = UV_IGNORE;
+ options.stdio[2].flags = UV_IGNORE;
+ */
+
+ /*
+ TODO: Handle creating pipes
+ options.stdio[0].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE;
+ options.stdio[1].flags = UV_CREATE_PIPE | UV_READABLE_PIPE;
+ options.stdio[2].flags = UV_CREATE_PIPE | UV_READABLE_PIPE;s
+ */
+
+ options.stdio[0].flags = UV_INHERIT_STREAM;
+ options.stdio[1].flags = UV_INHERIT_STREAM;
+ options.stdio[2].flags = UV_INHERIT_STREAM;
+
+ options.stdio[0].data.stream = stdin_stream;
+ options.stdio[1].data.stream = stdout_stream;
+ options.stdio[2].data.stream = stderr_stream;
/* Parse the args array */
argc = lua_objlen(L, 5) + 1;
@@ -103,11 +130,6 @@ int luv_spawn(lua_State* L) {
options.env = env ? env : luv_os_environ();
options.cwd = cwd;
-#if 0
- options.stdin_stream = stdin_stream;
- options.stdout_stream = stdout_stream;
- options.stderr_stream = stderr_stream;
-#endif
/* Create the userdata */
handle = luv_create_process(L);
View
1 tests/test-process.lua
@@ -15,6 +15,7 @@ function test()
child = spawn('bash', {'-c', 'set'}, options)
end
child.stdout:on('data', function(chunk)
+ print(chunk)
if chunk:find('TEST1=1') then
environmentTestResult = true
end

0 comments on commit 870fbbc

Please sign in to comment.