diff options
-rw-r--r-- | lem/io/core.c | 7 | ||||
-rw-r--r-- | lem/io/stream.c | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/lem/io/core.c b/lem/io/core.c index 15ebd8d..c56463c 100644 --- a/lem/io/core.c +++ b/lem/io/core.c @@ -255,12 +255,11 @@ push_stdstream(lua_State *L, int fd) struct stream *s; /* make the socket non-blocking */ - if (fcntl(fd, F_SETFL, O_NONBLOCK) == -1) - luaL_error(L, "error making fd %d non-blocking: %s", - fd, strerror(errno)); + fcntl(fd, F_SETFL, O_NONBLOCK); s = stream_new(L, fd, -2); - s->open = 2; /* don't close this in __gc() */ + /* don't close this in __gc(), but make it blocking again */ + s->open = 2; } int diff --git a/lem/io/stream.c b/lem/io/stream.c index 07aa5d2..204df81 100644 --- a/lem/io/stream.c +++ b/lem/io/stream.c @@ -56,6 +56,8 @@ stream_gc(lua_State *T) if (s->open & 1) close(s->r.fd); + if (s->open & 2) + fcntl(s->w.fd, F_SETFL, 0); return 0; } |