1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-26 12:10:59 +01:00

runProgram backup2

This commit is contained in:
Wouter den Breejen 2007-07-06 15:18:37 +00:00
parent 4f483aad0f
commit 0a4a3a1b68

View file

@ -772,6 +772,9 @@ void killUser(uid_t uid)
string runProgram(Path program, bool searchPath, const Strings & args)
{
/* Split args based on | for pipe-ing */
/* Create a pipe. */
Pipe pipe;
pipe.create();
@ -814,6 +817,12 @@ string runProgram(Path program, bool searchPath, const Strings & args)
pipe.writeSide.close();
/* Wait for the child to finish. */
int status = pid.wait(true);
if (!statusOk(status))
throw Error(format("program `%1%' %2%")
% program % statusToString(status));
// Create a pipe.
Pipe pipe2;
@ -863,15 +872,6 @@ string runProgram(Path program, bool searchPath, const Strings & args)
/* Parent. */
pipe2.writeSide.close();
string result = drainFD(pipe2.readSide);
/* Wait for the child to finish. */
int status = pid.wait(true);
if (!statusOk(status))
throw Error(format("program `%1%' %2%")
% program % statusToString(status));
/* wait for second ........... */
int status2 = pid2.wait(true);
@ -879,6 +879,8 @@ string runProgram(Path program, bool searchPath, const Strings & args)
throw Error(format("program `%1%' %2%")
% program % statusToString(status));
string result = drainFD(pipe2.readSide);
return result;
}