mirror of
https://github.com/NixOS/nix
synced 2025-06-27 00:11:17 +02:00
Hack to get SSH error messages from build-remote
E.g. cannot build on 'ssh://mac1': cannot connect to 'mac1': bash: nix-store: command not found cannot build on 'ssh://mac2': cannot connect to 'mac2': Host key verification failed. cannot build on 'ssh://mac3': cannot connect to 'mac3': Received disconnect from 213... port 6001:2: Too many authentication failures Authentication failed.
This commit is contained in:
parent
78d0c72b52
commit
1aca195e52
4 changed files with 33 additions and 7 deletions
|
@ -567,21 +567,38 @@ void writeFull(int fd, const string & s, bool allowInterrupts)
|
|||
}
|
||||
|
||||
|
||||
string drainFD(int fd)
|
||||
string drainFD(int fd, bool block)
|
||||
{
|
||||
StringSink sink;
|
||||
drainFD(fd, sink);
|
||||
drainFD(fd, sink, block);
|
||||
return std::move(*sink.s);
|
||||
}
|
||||
|
||||
|
||||
void drainFD(int fd, Sink & sink)
|
||||
void drainFD(int fd, Sink & sink, bool block)
|
||||
{
|
||||
int saved;
|
||||
|
||||
Finally finally([&]() {
|
||||
if (!block) {
|
||||
if (fcntl(fd, F_SETFL, saved) == -1)
|
||||
throw SysError("making file descriptor blocking");
|
||||
}
|
||||
});
|
||||
|
||||
if (!block) {
|
||||
saved = fcntl(fd, F_GETFL);
|
||||
if (fcntl(fd, F_SETFL, saved | O_NONBLOCK) == -1)
|
||||
throw SysError("making file descriptor non-blocking");
|
||||
}
|
||||
|
||||
std::vector<unsigned char> buf(4096);
|
||||
while (1) {
|
||||
checkInterrupt();
|
||||
ssize_t rd = read(fd, buf.data(), buf.size());
|
||||
if (rd == -1) {
|
||||
if (!block && (errno == EAGAIN || errno == EWOULDBLOCK))
|
||||
break;
|
||||
if (errno != EINTR)
|
||||
throw SysError("reading from file");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue