1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-05 08:11:47 +02:00

* Argh, another short-write problem. Added wrappers around

read()/write() to fix this once and for all.
This commit is contained in:
Eelco Dolstra 2003-07-20 21:11:43 +00:00
parent 667a6afb9d
commit 7984cfc7c1
9 changed files with 46 additions and 36 deletions

View file

@ -215,12 +215,7 @@ struct StdoutSink : DumpSink
virtual void operator ()
(const unsigned char * data, unsigned int len)
{
while (len) {
ssize_t res = write(STDOUT_FILENO, (char *) data, len);
if (res == -1) throw SysError("writing to stdout");
len -= res;
data += res;
}
writeFull(STDOUT_FILENO, data, len);
}
};
@ -247,15 +242,9 @@ static void opDump(Strings opFlags, Strings opArgs)
/* A source that read restore intput to stdin. */
struct StdinSource : RestoreSource
{
virtual void operator () (const unsigned char * data, unsigned int len)
virtual void operator () (unsigned char * data, unsigned int len)
{
while (len) {
ssize_t res = read(STDIN_FILENO, (char *) data, len);
if (res == -1) throw SysError("reading from stdin");
if (res == 0) throw Error("unexpected end-of-file on stdin");
len -= res;
data += res;
}
readFull(STDIN_FILENO, data, len);
}
};