mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 12:10:59 +01:00
runProgram backup2
This commit is contained in:
parent
4f483aad0f
commit
0a4a3a1b68
1 changed files with 11 additions and 9 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue