Skip to content

Commit 84914bb

Browse files
committed
memory analyzer: fail when gdb cannot be started
When gdb wasn't available, the forked child would not terminate and the parent would wait forever.
1 parent ac11ec8 commit 84914bb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/memory-analyzer/gdb_api.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,11 @@ void gdb_apit::create_gdb_process()
133133
// Only reachable, if execvp failed
134134
int errno_value = errno;
135135
dprintf(pipe_output[1], "errno in child: %s\n", strerror(errno_value));
136+
throw gdb_interaction_exceptiont("could not run gdb");
136137
}
137138
else
138139
{
139140
// parent process
140-
gdb_state = gdb_statet::CREATED;
141-
142141
close(pipe_input[0]);
143142
close(pipe_output[1]);
144143

@@ -148,6 +147,11 @@ void gdb_apit::create_gdb_process()
148147
// get stream for writing to gdb
149148
command_stream = fdopen(pipe_input[1], "w");
150149

150+
if(waitpid(gdb_process, 0, WNOHANG) == 0)
151+
throw gdb_interaction_exceptiont("could not run gdb");
152+
else
153+
gdb_state = gdb_statet::CREATED;
154+
151155
std::string line = read_most_recent_line();
152156
CHECK_RETURN(
153157
has_prefix(line, R"(~"done)") ||

0 commit comments

Comments
 (0)