From e38c438771d10231e7ce1b74c027b4914acd6c78 Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Tue, 3 Mar 2009 22:44:26 +0000 Subject: nixio: Use POSIX file functions introduce dup() introduce fork() wait() kill() more signal interrupt wrappers more POSIX / UNIX standard compliance --- libs/nixio/src/socket.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'libs/nixio/src/socket.c') diff --git a/libs/nixio/src/socket.c b/libs/nixio/src/socket.c index 258cdeece8..336f34812e 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; } -- cgit v1.2.3