diff options
author | Steven Barth <steven@midlink.org> | 2009-03-03 22:44:26 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2009-03-03 22:44:26 +0000 |
commit | e38c438771d10231e7ce1b74c027b4914acd6c78 (patch) | |
tree | 91ca365e48919d9af60e11ec7564f47538208289 /libs/nixio/src/socket.c | |
parent | a3079828b4e0c0fabd96dfca87b99a5b5d9529e5 (diff) |
nixio:
Use POSIX file functions
introduce dup()
introduce fork() wait() kill()
more signal interrupt wrappers
more POSIX / UNIX standard compliance
Diffstat (limited to 'libs/nixio/src/socket.c')
-rw-r--r-- | libs/nixio/src/socket.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/libs/nixio/src/socket.c b/libs/nixio/src/socket.c index 258cdeece..336f34812 100644 --- a/libs/nixio/src/socket.c +++ b/libs/nixio/src/socket.c @@ -91,8 +91,14 @@ static int nixio_socket(lua_State *L) { static int nixio_sock_close(lua_State *L) { nixio_sock *sock = nixio__checksock(L); int sockfd = sock->fd; + int res; sock->fd = -1; - return nixio__pstatus(L, !close(sockfd)); + + do { + res = close(sockfd); + } while (res == -1 && errno == EINTR); + + return nixio__pstatus(L, !res); } /** @@ -100,8 +106,11 @@ static int nixio_sock_close(lua_State *L) { */ static int nixio_sock__gc(lua_State *L) { nixio_sock *sock = (nixio_sock*)luaL_checkudata(L, 1, NIXIO_META); + int res; if (sock && sock->fd != -1) { - close(sock->fd); + do { + res = close(sock->fd); + } while (res == -1 && errno == EINTR); } return 0; } |