diff options
| author | tgoodwin <tgoodwin> | 1998-02-17 13:48:31 +0000 |
|---|---|---|
| committer | Toby Goodwin <toby@paccrat.org> | 2015-05-16 21:23:04 +0100 |
| commit | 7cdc7259c1b514197fee5a0d973f95fdf3347677 (patch) | |
| tree | 35d87b214d3617930e431f1d0aeee78c8298da5c /utils.c | |
| parent | 2af5bbbb5355e9fcf311673f8051952c6b9b2509 (diff) | |
split some restartable syscall stuff out
don't declare slowbuf unless it's needed
Diffstat (limited to 'utils.c')
| -rw-r--r-- | utils.c | 43 |
1 files changed, 0 insertions, 43 deletions
@@ -65,49 +65,6 @@ extern bool isabsolute(char *path) { return path[0] == '/' || (path[0] == '.' && (path[1] == '/' || (path[1] == '.' && path[2] == '/'))); } -/* signal-safe read and write (for BSD slow devices). writeall also allows partial writes */ -static char *safe_buf; -static size_t safe_remain; - -extern void writeall(int fd, char *buf, size_t remain) { - int i; - - safe_buf = buf; - safe_remain = remain; - for (i = 0; safe_remain > 0; buf += i, safe_remain -= i) { - interrupt_happened = FALSE; - if (!sigsetjmp(slowbuf.j, 1)) { - slow = TRUE; - if (interrupt_happened) - break; - else if ((i = write(fd, safe_buf, safe_remain)) <= 0) - break; /* abort silently on errors in write() */ - } else - break; - slow = FALSE; - } - slow = FALSE; - sigchk(); -} - -extern int rc_read(int fd, char *buf, size_t n) { - long /*ssize_t*/ r; - interrupt_happened = FALSE; - if (!sigsetjmp(slowbuf.j, 1)) { - slow = TRUE; - if (!interrupt_happened) - r = read(fd, buf, n); - else - r = -2; - } else - r = -2; - slow = FALSE; - if (r == -2) { - errno = EINTR; - r = -1; - } - return r; -} /* duplicate a fd and close the old one only if necessary */ |