From bb146866c04bc942242a53d110716f161519a721 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 17 Oct 2017 10:57:38 +0200 Subject: executor: improvements for akaros 1. remove workaround for pthread attrs (was fixed in akaros) 2. remove workaround for dup2 (was fixed in akaros) 3. check that we receive a program 4. implement timeout for test processes --- executor/executor_akaros.cc | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'executor/executor_akaros.cc') diff --git a/executor/executor_akaros.cc b/executor/executor_akaros.cc index e7d828a40..f70e83807 100644 --- a/executor/executor_akaros.cc +++ b/executor/executor_akaros.cc @@ -3,9 +3,6 @@ // +build -// https://github.com/brho/akaros/issues/41 -#define DUP2_BROKEN - #define SYZ_EXECUTOR #include "common_akaros.h" @@ -31,7 +28,7 @@ int main(int argc, char** argv) reply_handshake(); for (;;) { - receive_execute(); + receive_execute(true); char cwdbuf[128] = "/syz-tmpXXXXXX"; mkdtemp(cwdbuf); int pid = fork(); @@ -45,10 +42,26 @@ int main(int argc, char** argv) execute_one(); doexit(0); } - // TODO: timeout. int status = 0; - while (waitpid(pid, &status, 0) != pid) { + uint64_t start = current_time_ms(); + for (;;) { + int res = waitpid(pid, &status, WNOHANG); + if (res == pid) + break; + sleep_ms(10); + uint64_t now = current_time_ms(); + if (now - start < 3 * 1000) + continue; + kill(pid, SIGKILL); + while (waitpid(pid, &status, 0) != pid) { + } + break; } + status = WEXITSTATUS(status); + if (status == kFailStatus) + fail("child failed"); + if (status == kErrorStatus) + error("child errored"); remove_dir(cwdbuf); reply_execute(0); } -- cgit mrf-deployment