diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-10-17 10:57:38 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-10-17 10:57:38 +0200 |
| commit | bb146866c04bc942242a53d110716f161519a721 (patch) | |
| tree | 183ecb8c9c22f709b8db1cc6ffa10118ce1f81fd /executor/executor_akaros.cc | |
| parent | a8a0b01a8bc49b2088d33c529198d4780f66b94a (diff) | |
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
Diffstat (limited to 'executor/executor_akaros.cc')
| -rw-r--r-- | executor/executor_akaros.cc | 25 |
1 files changed, 19 insertions, 6 deletions
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); } |
