File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change 19
19
# include < iostream>
20
20
# include < vector>
21
21
22
+ # include " exception_utils.h"
22
23
# include " invariant.h"
23
24
# include " narrow.h"
24
25
# include " optional.h"
@@ -35,20 +36,20 @@ piped_processt::piped_processt(const std::vector<std::string> commandvec)
35
36
36
37
if (pipe (pipe_input) == -1 )
37
38
{
38
- throw std::runtime_error (" Input pipe creation failed" );
39
+ throw system_exceptiont (" Input pipe creation failed" );
39
40
}
40
41
41
42
if (pipe (pipe_output) == -1 )
42
43
{
43
- throw std::runtime_error (" Output pipe creation failed" );
44
+ throw system_exceptiont (" Output pipe creation failed" );
44
45
}
45
46
46
47
// Default state
47
48
process_state = statet::NOT_CREATED;
48
49
49
50
if (fcntl (pipe_output[0 ], F_SETFL, O_NONBLOCK) < 0 )
50
51
{
51
- throw std::runtime_error (" Setting pipe non-blocking failed" );
52
+ throw system_exceptiont (" Setting pipe non-blocking failed" );
52
53
}
53
54
54
55
// Create a new process for the child that will execute the
@@ -114,7 +115,7 @@ piped_processt::~piped_processt()
114
115
# ifdef _WIN32
115
116
UNIMPLEMENTED_FEATURE (" Pipe IPC on windows: piped_processt constructor" )
116
117
# else
117
- // Close the parent side of the remaning pipes
118
+ // Close the parent side of the remaining pipes
118
119
fclose (command_stream);
119
120
// Note that the above will call close(pipe_input[1]);
120
121
close (pipe_output[0 ]);
Original file line number Diff line number Diff line change @@ -84,6 +84,10 @@ class piped_processt
84
84
// Child process ID.
85
85
pid_t pid;
86
86
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.
87
91
int pipe_input[2 ];
88
92
int pipe_output[2 ];
89
93
statet process_state;
You can’t perform that action at this time.
0 commit comments