aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2024-07-08 09:54:32 +0200
committerDmitry Vyukov <dvyukov@google.com>2024-07-08 08:57:25 +0000
commitcde64f7d2183d8d136abd936a86c41a83757a9fe (patch)
tree0c6c0359874d91b63ddad5af45c1fd73ab22901d
parente03bdbc0e5550821e70d48113e1b3a12c913cc36 (diff)
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).
-rw-r--r--executor/executor.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/executor/executor.cc b/executor/executor.cc
index 862b0776e..ec3bdcc74 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);