diff options
author | Jeremy Harris <jgh146exb@wizmail.org> | 2019-12-17 20:35:28 +0000 |
---|---|---|
committer | Jeremy Harris <jgh146exb@wizmail.org> | 2019-12-18 00:07:22 +0000 |
commit | 2791749f220602482c2cce772e6520c54218c0dd (patch) | |
tree | 63f24cfce6199d0ced7bfe06f1456a797c3b1760 /src/OS | |
parent | f8f40a64d41c4d47b974810320ab257e2eac0cf3 (diff) |
GNU/Hurd: retry EINTR returns from pipe I/O
Replaces: a76f64c3d4
Diffstat (limited to 'src/OS')
-rw-r--r-- | src/OS/Makefile-Base | 6 | ||||
-rw-r--r-- | src/OS/os.c-GNU | 35 | ||||
-rw-r--r-- | src/OS/os.h-GNU | 6 |
3 files changed, 44 insertions, 3 deletions
diff --git a/src/OS/Makefile-Base b/src/OS/Makefile-Base index 36af8308d..1ab3ac35f 100644 --- a/src/OS/Makefile-Base +++ b/src/OS/Makefile-Base @@ -644,7 +644,8 @@ HDRS = blob.h \ mytypes.h \ sha_ver.h \ structs.h \ - os.h + os.h \ + osfunctions.h PHDRS = ../config.h \ ../dbfunctions.h \ ../dbstuff.h \ @@ -655,7 +656,8 @@ PHDRS = ../config.h \ ../macros.h \ ../mytypes.h \ ../structs.h \ - ../os.h + ../os.h \ + ../osfunctions.h .SUFFIXES: .o .c .c.o:; @echo "$(CC) $*.c" diff --git a/src/OS/os.c-GNU b/src/OS/os.c-GNU index e5d6ff66c..06226839b 100644 --- a/src/OS/os.c-GNU +++ b/src/OS/os.c-GNU @@ -52,4 +52,39 @@ return -1; } #endif /* OS_LOAD_AVERAGE */ + +ssize_t +os_pipe_read(int fd, void * buf, size_t count) +{ +for (int rc, retries = 10; retries > 0; retries--) + { + if ((rc = read(fd, buf, count) >= 0) break; + if (rc != -1 || errno != EINTR) break; + } +return rc; +} + + +ssize_t +os_pipe_write(int fd, void * buf, size_t count) +{ +for (int rc, retries = 10; retries > 0; retries--) + { + if ((rc = write(fd, buf, count) >= 0) break; + if (rc != -1 || errno != EINTR) break; + } +return rc; +} + +ssize_t +os_pipe_writev(int fd, const struct iovec * iov, int iovcnt +{ +for (int rc, retries = 10; retries > 0; retries--) + { + if ((rc = writev(fd, iov, iovcnt) >= 0) break; + if (rc != -1 || errno != EINTR) break; + } +return rc; +} + /* End of os.c-GNU */ diff --git a/src/OS/os.h-GNU b/src/OS/os.h-GNU index 1de2e3e84..772d278ad 100644 --- a/src/OS/os.h-GNU +++ b/src/OS/os.h-GNU @@ -21,7 +21,11 @@ typedef struct flock flock_t; #define ICONV_ARG2_TYPE const char ** /* setgroups(0, NULL) succeeds, and drops the gid group -as well as any supplementary groups*/ +as well as any supplementary groups */ #define OS_SETGROUPS_ZERO_DROPS_ALL +/* reads and writes on pipes frequently return EINTR. We provide +a routine to retry that */ +#define OS_PIPE_RW_EINTR + /* End */ |