Skip to content
Snippets Groups Projects
Commit c25da1dd authored by Zubin's avatar Zubin Committed by Matthew Pickering
Browse files

Fix forking

1. When forking, don't repond to a pause request in the parent after the child has already responded

2. use waitpid() instead of wait() because wait can race with other wait() calls in the program
parent acb4f683
No related branches found
No related tags found
No related merge requests found
......@@ -218,7 +218,7 @@ static StgStablePtr rts_saved_closure = NULL;
extern "C"
void pause_mutator() {
void pause_mutator(Response &resp) {
trace("pausing mutator\n");
pid_t pid;
if (use_fork){
......@@ -233,10 +233,11 @@ void pause_mutator() {
r_poll_pause_resp->finish(RESP_OKAY);
}
paused = true;
resp.finish(RESP_OKAY);
}
else {
int status = 0;
wait(&status);
waitpid(pid,&status,0);
use_fork = false;
}
}
......@@ -412,8 +413,7 @@ static int handle_command(Socket& sock, const char *buf, uint32_t cmd_len) {
resp.finish(RESP_ALREADY_PAUSED);
} else {
trace("fork?: %s\n", use_fork ? "yes" : "no");
pause_mutator();
resp.finish(RESP_OKAY);
pause_mutator(resp);
}
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment