Skip to content

Commit 5eb6a96

Browse files
committed
[FIXUP] Implement some of Peter's changes.
1 parent 1e2419c commit 5eb6a96

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/util/piped_process.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# include <iostream>
2020
# include <vector>
2121

22+
# include "exception_utils.h"
2223
# include "invariant.h"
2324
# include "narrow.h"
2425
# include "optional.h"
@@ -35,20 +36,20 @@ piped_processt::piped_processt(const std::vector<std::string> commandvec)
3536

3637
if(pipe(pipe_input) == -1)
3738
{
38-
throw std::runtime_error("Input pipe creation failed");
39+
throw system_exceptiont("Input pipe creation failed");
3940
}
4041

4142
if(pipe(pipe_output) == -1)
4243
{
43-
throw std::runtime_error("Output pipe creation failed");
44+
throw system_exceptiont("Output pipe creation failed");
4445
}
4546

4647
// Default state
4748
process_state = statet::NOT_CREATED;
4849

4950
if(fcntl(pipe_output[0], F_SETFL, O_NONBLOCK) < 0)
5051
{
51-
throw std::runtime_error("Setting pipe non-blocking failed");
52+
throw system_exceptiont("Setting pipe non-blocking failed");
5253
}
5354

5455
// Create a new process for the child that will execute the
@@ -114,7 +115,7 @@ piped_processt::~piped_processt()
114115
# ifdef _WIN32
115116
UNIMPLEMENTED_FEATURE("Pipe IPC on windows: piped_processt constructor")
116117
# else
117-
// Close the parent side of the remaning pipes
118+
// Close the parent side of the remaining pipes
118119
fclose(command_stream);
119120
// Note that the above will call close(pipe_input[1]);
120121
close(pipe_output[0]);

src/util/piped_process.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ class piped_processt
8484
// Child process ID.
8585
pid_t pid;
8686
FILE *command_stream;
87+
// The member fields below are so named from the perspective of the
88+
// parent -> child process. So `pipe_input` is where we are feeding
89+
// commands to the child process, and `pipe_output` is where we read
90+
// the results of execution from.
8791
int pipe_input[2];
8892
int pipe_output[2];
8993
statet process_state;

0 commit comments

Comments
 (0)