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