diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-02-20 10:50:27 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-02-20 10:50:27 -0300 |
commit | e39e758a73c08953d477c8e024ffbd1e2edfe6a5 (patch) | |
tree | 6d710ebf5278bc10ab085076c4fb13fe9fb280b9 /liolib.c | |
parent | 5438d77221e5f909b2f1990721ec56ec352b932b (diff) | |
download | lua-e39e758a73c08953d477c8e024ffbd1e2edfe6a5.tar.gz lua-e39e758a73c08953d477c8e024ffbd1e2edfe6a5.tar.bz2 lua-e39e758a73c08953d477c8e024ffbd1e2edfe6a5.zip |
closing a "popen" file returns the process exit status
Diffstat (limited to 'liolib.c')
-rw-r--r-- | liolib.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: liolib.c,v 2.78 2008/02/12 16:51:03 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 2.79 2008/02/12 17:05:36 roberto Exp roberto $ |
3 | ** Standard I/O (and system) library | 3 | ** Standard I/O (and system) library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -106,9 +106,14 @@ static int io_noclose (lua_State *L) { | |||
106 | */ | 106 | */ |
107 | static int io_pclose (lua_State *L) { | 107 | static int io_pclose (lua_State *L) { |
108 | FILE **p = tofilep(L); | 108 | FILE **p = tofilep(L); |
109 | int ok = lua_pclose(L, *p); | 109 | int stat = lua_pclose(L, *p); |
110 | *p = NULL; | 110 | *p = NULL; |
111 | return pushresult(L, ok, NULL); | 111 | if (stat == -1) /* error? */ |
112 | return pushresult(L, 0, NULL); | ||
113 | else { | ||
114 | lua_pushinteger(L, stat); | ||
115 | return 1; /* return status */ | ||
116 | } | ||
112 | } | 117 | } |
113 | 118 | ||
114 | 119 | ||