mirror of
https://github.com/lua/lua.git
synced 2025-02-04 06:13:04 +08:00
closing a "popen" file returns the process exit status
This commit is contained in:
parent
5438d77221
commit
e39e758a73
11
liolib.c
11
liolib.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: liolib.c,v 2.78 2008/02/12 16:51:03 roberto Exp roberto $
|
** $Id: liolib.c,v 2.79 2008/02/12 17:05:36 roberto Exp roberto $
|
||||||
** Standard I/O (and system) library
|
** Standard I/O (and system) library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -106,9 +106,14 @@ static int io_noclose (lua_State *L) {
|
|||||||
*/
|
*/
|
||||||
static int io_pclose (lua_State *L) {
|
static int io_pclose (lua_State *L) {
|
||||||
FILE **p = tofilep(L);
|
FILE **p = tofilep(L);
|
||||||
int ok = lua_pclose(L, *p);
|
int stat = lua_pclose(L, *p);
|
||||||
*p = NULL;
|
*p = NULL;
|
||||||
return pushresult(L, ok, NULL);
|
if (stat == -1) /* error? */
|
||||||
|
return pushresult(L, 0, NULL);
|
||||||
|
else {
|
||||||
|
lua_pushinteger(L, stat);
|
||||||
|
return 1; /* return status */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: luaconf.h,v 1.101 2009/02/07 12:23:15 roberto Exp roberto $
|
** $Id: luaconf.h,v 1.102 2009/02/18 13:17:10 roberto Exp roberto $
|
||||||
** Configuration file for Lua
|
** Configuration file for Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -695,18 +695,18 @@ union luai_Cast { double l_d; long l_l; };
|
|||||||
#if defined(LUA_USE_POPEN)
|
#if defined(LUA_USE_POPEN)
|
||||||
|
|
||||||
#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m))
|
#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m))
|
||||||
#define lua_pclose(L,file) ((void)L, (pclose(file) != -1))
|
#define lua_pclose(L,file) ((void)L, pclose(file))
|
||||||
|
|
||||||
#elif defined(LUA_WIN)
|
#elif defined(LUA_WIN)
|
||||||
|
|
||||||
#define lua_popen(L,c,m) ((void)L, _popen(c,m))
|
#define lua_popen(L,c,m) ((void)L, _popen(c,m))
|
||||||
#define lua_pclose(L,file) ((void)L, (_pclose(file) != -1))
|
#define lua_pclose(L,file) ((void)L, _pclose(file))
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define lua_popen(L,c,m) ((void)((void)c, m), \
|
#define lua_popen(L,c,m) ((void)((void)c, m), \
|
||||||
luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0)
|
luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0)
|
||||||
#define lua_pclose(L,file) ((void)((void)L, file), 0)
|
#define lua_pclose(L,file) ((void)((void)L, file), -1)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user