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)
|
string runProgram(Path program, bool searchPath, const Strings & args)
|
||||||
{
|
{
|
||||||
|
/* Split args based on | for pipe-ing */
|
||||||
|
|
||||||
|
|
||||||
/* Create a pipe. */
|
/* Create a pipe. */
|
||||||
Pipe pipe;
|
Pipe pipe;
|
||||||
pipe.create();
|
pipe.create();
|
||||||
|
|
@ -814,6 +817,12 @@ string runProgram(Path program, bool searchPath, const Strings & args)
|
||||||
|
|
||||||
pipe.writeSide.close();
|
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.
|
// Create a pipe.
|
||||||
Pipe pipe2;
|
Pipe pipe2;
|
||||||
|
|
@ -863,15 +872,6 @@ string runProgram(Path program, bool searchPath, const Strings & args)
|
||||||
/* Parent. */
|
/* Parent. */
|
||||||
|
|
||||||
pipe2.writeSide.close();
|
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 ........... */
|
/* wait for second ........... */
|
||||||
int status2 = pid2.wait(true);
|
int status2 = pid2.wait(true);
|
||||||
|
|
@ -879,6 +879,8 @@ string runProgram(Path program, bool searchPath, const Strings & args)
|
||||||
throw Error(format("program `%1%' %2%")
|
throw Error(format("program `%1%' %2%")
|
||||||
% program % statusToString(status));
|
% program % statusToString(status));
|
||||||
|
|
||||||
|
|
||||||
|
string result = drainFD(pipe2.readSide);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue