From efcf24be0c22cba57b298161bf4ab0561fd3c08e Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 22 May 2020 15:39:29 -0300 Subject: '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. --- liolib.c | 1 + 1 file changed, 1 insertion(+) (limited to 'liolib.c') 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) { */ static int io_pclose (lua_State *L) { LStream *p = tolstream(L); + errno = 0; return luaL_execresult(L, l_pclose(L, p->f)); } -- cgit v1.2.3-55-g6feb