From 302b581ddc1f9dcee5c1bcb32da558ae2a7b24c1 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 19 Apr 2002 02:08:52 +0000 Subject: First cut at fix for the EINTR problem... More needs to be done I think. Jeremy. (This used to be commit 48475a7a697242b9fd7b1aec24389afb112569c4) --- source3/lib/system.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'source3/lib/system.c') diff --git a/source3/lib/system.c b/source3/lib/system.c index 8c7eec939e..d97751eb4b 100644 --- a/source3/lib/system.c +++ b/source3/lib/system.c @@ -72,6 +72,51 @@ int sys_usleep(long usecs) #endif /* HAVE_USLEEP */ } +/******************************************************************* +A read wrapper that will deal with EINTR. +********************************************************************/ + +ssize_t sys_read(int fd, void *buf, size_t count) +{ + ssize_t ret; + + do { + errno = 0; + ret = read(fd, buf, count); + } while (ret == -1 && errno == EINTR); + return ret; +} + +/******************************************************************* +A write wrapper that will deal with EINTR. +********************************************************************/ + +ssize_t sys_write(int fd, const void *buf, size_t count) +{ + ssize_t ret; + + do { + errno = 0; + ret = write(fd, buf, count); + } while (ret == -1 && errno == EINTR); + return ret; +} + +/******************************************************************* +A send wrapper that will deal with EINTR. +********************************************************************/ + +int sys_send(int s, const void *msg, size_t len, int flags) +{ + ssize_t ret; + + do { + errno = 0; + ret = send(s, msg, len, flags); + } while (ret == -1 && errno == EINTR); + return ret; +} + /******************************************************************* A stat() wrapper that will deal with 64 bit filesizes. ********************************************************************/ -- cgit