From cde64f7d2183d8d136abd936a86c41a83757a9fe Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 8 Jul 2024 09:54:32 +0200 Subject: [PATCH] executor: handle EINTR when reading from control pipe Handle EINTR errors. Sometimes I see them happenning when running in debug mode. Before the previous commit, each such error was printed to output and detected as a bug. Without debug these should be retried by restarting the process, but still better to handle w/o restarting the process (may be expensive). --- executor/executor.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/executor/executor.cc b/executor/executor.cc index 862b0776ed5f..ec3bdcc746fe 100644 --- a/executor/executor.cc +++ b/executor/executor.cc @@ -721,11 +721,11 @@ void receive_handshake() void receive_execute() { execute_req req = {}; - ssize_t n = read(kInPipeFd, &req, sizeof(req)); + ssize_t n = 0; + while ((n = read(kInPipeFd, &req, sizeof(req))) == -1 && errno == EINTR) + ; if (n != (ssize_t)sizeof(req)) failmsg("control pipe read failed", "read=%zd want=%zd", n, sizeof(req)); - if (req.magic != kInMagic) - failmsg("bad execute request magic", "magic=0x%llx", req.magic); request_id = req.id; flag_collect_signal = req.exec_flags & (1 << 0); flag_collect_cover = req.exec_flags & (1 << 1);