# HG changeset patch # User jbe # Date 1435018259 -7200 # Node ID e53da349fd8f4d0cedd2b324f325598098abde9a # Parent 35ea31e45b4319a1dcd20cc7e7555464d5c66f8d Clarified nil/false return values of poll function and wait_nb method diff -r 35ea31e45b43 -r e53da349fd8f moonbridge_io.c --- a/moonbridge_io.c Tue Jun 23 02:07:26 2015 +0200 +++ b/moonbridge_io.c Tue Jun 23 02:10:59 2015 +0200 @@ -1464,7 +1464,9 @@ } } if (!waitedpid) { - lua_pushnil(L); + lua_pushboolean(L, 0); + lua_pushliteral(L, "Process is still running"); + return 2; } else { child->pid = 0; if (WIFEXITED(status)) { @@ -1474,8 +1476,8 @@ } else { luaL_error(L, "Unexpected status value returned by waitpid call"); } + return 1; } - return 1; } static int moonbr_io_wait(lua_State *L) { diff -r 35ea31e45b43 -r e53da349fd8f reference.txt --- a/reference.txt Tue Jun 23 02:07:26 2015 +0200 +++ b/reference.txt Tue Jun 23 02:10:59 2015 +0200 @@ -318,7 +318,8 @@ which corresponds to the respective positive signal number. The method :wait_nb() is the same as :wait(), except that it does not block but -returns nil if the child process has not terminated yet. +returns false (plus a notice as second return value) if the child process has +not terminated yet. The method :wait_call() is the same as :wait() but calls waitfunc() (in an infinite loop) as long as the process is still running. @@ -381,9 +382,9 @@ which does evaluate to true. If a set is nil, it is treated as being empty. Returns true when at least one file descriptor or handle is ready for reading -or writing respectively. Returns false (as first return value) plus a status -message (as second return value) in case of timeout or when a signal was -received. +or writing respectively. Returns false (plus a notice as second return value) +in case of timeout. Returns nil (plus a notice as second return value) if a +signal was received during waiting. ### moonbridge_io.tcpconnect(hostname, port)