Skip to content

Commit

Permalink
fix(spawn): invalid command
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Phillips committed Jan 7, 2015
1 parent 96f9cbc commit 527ef80
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/process.c
Expand Up @@ -213,7 +213,10 @@ static int luv_spawn(lua_State* L) {
ret = uv_spawn(luv_loop(L), handle, &options);

luv_clean_options(&options);
if (ret < 0) return luv_error(L, ret);
if (ret < 0) {
uv_close(handle, NULL);
return luv_error(L, ret);
}
lua_pushinteger(L, handle->pid);
return 2;
}
Expand Down
9 changes: 9 additions & 0 deletions tests/test-process.lua
Expand Up @@ -59,6 +59,15 @@ return require('lib/tap')(function (test)
uv.process_kill(handle, "sigterm")
end)

test("invalid command", function (print, p, expect, uv)
local handle, err
handle, err = uv.spawn("ksjdfksjdflkjsflksdf", {}, function(exit, code)
assert(false)
end)
assert(handle == nil)
assert(err)
end)

test("process stdio", function (print, p, expect, uv)
local stdin = uv.new_pipe(false)
local stdout = uv.new_pipe(false)
Expand Down

0 comments on commit 527ef80

Please sign in to comment.