forked from lix-project/hydra
Merge pull request #1189 from NixOS/fix-hang
openConnection(): Don't throw exceptions in forked child
This commit is contained in:
commit
84f54cb011
1 changed files with 23 additions and 25 deletions
|
@ -55,25 +55,11 @@ static void openConnection(Machine::ptr machine, Path tmpDir, int stderrFD, Chil
|
||||||
to.create();
|
to.create();
|
||||||
from.create();
|
from.create();
|
||||||
|
|
||||||
child.pid = startProcess([&]() {
|
|
||||||
|
|
||||||
restoreProcessContext();
|
|
||||||
|
|
||||||
if (dup2(to.readSide.get(), STDIN_FILENO) == -1)
|
|
||||||
throw SysError("cannot dup input pipe to stdin");
|
|
||||||
|
|
||||||
if (dup2(from.writeSide.get(), STDOUT_FILENO) == -1)
|
|
||||||
throw SysError("cannot dup output pipe to stdout");
|
|
||||||
|
|
||||||
if (dup2(stderrFD, STDERR_FILENO) == -1)
|
|
||||||
throw SysError("cannot dup stderr");
|
|
||||||
|
|
||||||
Strings argv;
|
Strings argv;
|
||||||
if (machine->isLocalhost()) {
|
if (machine->isLocalhost()) {
|
||||||
pgmName = "nix-store";
|
pgmName = "nix-store";
|
||||||
argv = {"nix-store", "--builders", "", "--serve", "--write"};
|
argv = {"nix-store", "--builders", "", "--serve", "--write"};
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
pgmName = "ssh";
|
pgmName = "ssh";
|
||||||
auto sshName = machine->sshName;
|
auto sshName = machine->sshName;
|
||||||
Strings extraArgs = extraStoreArgs(sshName);
|
Strings extraArgs = extraStoreArgs(sshName);
|
||||||
|
@ -92,6 +78,18 @@ static void openConnection(Machine::ptr machine, Path tmpDir, int stderrFD, Chil
|
||||||
append(argv, extraArgs);
|
append(argv, extraArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
child.pid = startProcess([&]() {
|
||||||
|
restoreProcessContext();
|
||||||
|
|
||||||
|
if (dup2(to.readSide.get(), STDIN_FILENO) == -1)
|
||||||
|
throw SysError("cannot dup input pipe to stdin");
|
||||||
|
|
||||||
|
if (dup2(from.writeSide.get(), STDOUT_FILENO) == -1)
|
||||||
|
throw SysError("cannot dup output pipe to stdout");
|
||||||
|
|
||||||
|
if (dup2(stderrFD, STDERR_FILENO) == -1)
|
||||||
|
throw SysError("cannot dup stderr");
|
||||||
|
|
||||||
execvp(argv.front().c_str(), (char * *) stringsToCharPtrs(argv).data()); // FIXME: remove cast
|
execvp(argv.front().c_str(), (char * *) stringsToCharPtrs(argv).data()); // FIXME: remove cast
|
||||||
|
|
||||||
throw SysError("cannot start %s", pgmName);
|
throw SysError("cannot start %s", pgmName);
|
||||||
|
|
Loading…
Reference in a new issue