Commit | Line | Data |
---|---|---|
2117e02e MW |
1 | #include "stralloc.h" |
2 | #include "readwrite.h" | |
3 | #include "slurpclose.h" | |
212b6f5d | 4 | #include "error.h" |
2117e02e MW |
5 | |
6 | int slurpclose(fd,sa,bufsize) | |
7 | int fd; | |
8 | stralloc *sa; | |
9 | int bufsize; | |
10 | { | |
11 | int r; | |
12 | for (;;) { | |
13 | if (!stralloc_readyplus(sa,bufsize)) { close(fd); return -1; } | |
14 | r = read(fd,sa->s + sa->len,bufsize); | |
212b6f5d | 15 | if (r == -1) if (errno == error_intr) continue; |
2117e02e MW |
16 | if (r <= 0) { close(fd); return r; } |
17 | sa->len += r; | |
18 | } | |
19 | } |