libs/nixio: don't close stdin, stdout or stderr during garbage collection
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 19 Jul 2009 02:39:10 +0000 (02:39 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 19 Jul 2009 02:39:10 +0000 (02:39 +0000)
libs/nixio/src/file.c

index 70c717e..9f99fb8 100644 (file)
@@ -329,7 +329,7 @@ static int nixio_file_close(lua_State *L) {
 static int nixio_file__gc(lua_State *L) {
        int *fdp = luaL_checkudata(L, 1, NIXIO_FILE_META);
        int res;
 static int nixio_file__gc(lua_State *L) {
        int *fdp = luaL_checkudata(L, 1, NIXIO_FILE_META);
        int res;
-       if (*fdp != -1) {
+       if (*fdp > 2) {
                do {
                        res = close(*fdp);
                } while (res == -1 && errno == EINTR);
                do {
                        res = close(*fdp);
                } while (res == -1 && errno == EINTR);