aboutsummaryrefslogtreecommitdiff
path: root/liolib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-05-22 15:39:29 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-05-22 15:39:29 -0300
commitefcf24be0c22cba57b298161bf4ab0561fd3c08e (patch)
tree5e6846467880a472a00ec02f3e27ca800884e161 /liolib.c
parent17dbaa8639505c9ad1a9946591f5960123fbd741 (diff)
downloadlua-efcf24be0c22cba57b298161bf4ab0561fd3c08e.tar.gz
lua-efcf24be0c22cba57b298161bf4ab0561fd3c08e.tar.bz2
lua-efcf24be0c22cba57b298161bf4ab0561fd3c08e.zip
'luaL_execresult' does not assume -1 status as error
ISO C is silent about the return of 'system'. Windows sets 'errno' in case of errors. Linux has several different error cases, with different return values. ISO C allows 'system' to set 'errno' even if there are no errors. Here we assume that a status==0 is success (which is the case on several platforms), otherwise it is an error. If there is an error number, gives the error based on it. (The worst a spurious 'errno' can do is to generate a bad error message.) Otherwise uses the normal results.
Diffstat (limited to 'liolib.c')
-rw-r--r--liolib.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/liolib.c b/liolib.c
index 08d18397..7ac34443 100644
--- a/liolib.c
+++ b/liolib.c
@@ -270,6 +270,7 @@ static int io_open (lua_State *L) {
270*/ 270*/
271static int io_pclose (lua_State *L) { 271static int io_pclose (lua_State *L) {
272 LStream *p = tolstream(L); 272 LStream *p = tolstream(L);
273 errno = 0;
273 return luaL_execresult(L, l_pclose(L, p->f)); 274 return luaL_execresult(L, l_pclose(L, p->f));
274} 275}
275 276