moonbridge
changeset 219:e53da349fd8f
Clarified nil/false return values of poll function and wait_nb method
author | jbe |
---|---|
date | Tue Jun 23 02:10:59 2015 +0200 (2015-06-23) |
parents | 35ea31e45b43 |
children | 6c02564342fe |
files | moonbridge_io.c reference.txt |
line diff
1.1 --- a/moonbridge_io.c Tue Jun 23 02:07:26 2015 +0200 1.2 +++ b/moonbridge_io.c Tue Jun 23 02:10:59 2015 +0200 1.3 @@ -1464,7 +1464,9 @@ 1.4 } 1.5 } 1.6 if (!waitedpid) { 1.7 - lua_pushnil(L); 1.8 + lua_pushboolean(L, 0); 1.9 + lua_pushliteral(L, "Process is still running"); 1.10 + return 2; 1.11 } else { 1.12 child->pid = 0; 1.13 if (WIFEXITED(status)) { 1.14 @@ -1474,8 +1476,8 @@ 1.15 } else { 1.16 luaL_error(L, "Unexpected status value returned by waitpid call"); 1.17 } 1.18 + return 1; 1.19 } 1.20 - return 1; 1.21 } 1.22 1.23 static int moonbr_io_wait(lua_State *L) {
2.1 --- a/reference.txt Tue Jun 23 02:07:26 2015 +0200 2.2 +++ b/reference.txt Tue Jun 23 02:10:59 2015 +0200 2.3 @@ -318,7 +318,8 @@ 2.4 which corresponds to the respective positive signal number. 2.5 2.6 The method :wait_nb() is the same as :wait(), except that it does not block but 2.7 -returns nil if the child process has not terminated yet. 2.8 +returns false (plus a notice as second return value) if the child process has 2.9 +not terminated yet. 2.10 2.11 The method :wait_call() is the same as :wait() but calls waitfunc() (in an 2.12 infinite loop) as long as the process is still running. 2.13 @@ -381,9 +382,9 @@ 2.14 which does evaluate to true. If a set is nil, it is treated as being empty. 2.15 2.16 Returns true when at least one file descriptor or handle is ready for reading 2.17 -or writing respectively. Returns false (as first return value) plus a status 2.18 -message (as second return value) in case of timeout or when a signal was 2.19 -received. 2.20 +or writing respectively. Returns false (plus a notice as second return value) 2.21 +in case of timeout. Returns nil (plus a notice as second return value) if a 2.22 +signal was received during waiting. 2.23 2.24 2.25 ### moonbridge_io.tcpconnect(hostname, port)