From 5a5a1919bdba8d7bde4c20d77c966b155b8f6bf1 Mon Sep 17 00:00:00 2001 From: Denis Smirnov <sd@picodata.io> Date: Thu, 10 Aug 2023 10:53:43 +0700 Subject: [PATCH] fix: parent-child ipc communication When picodata process forks, the parent and child are connected by two unix pipes: - the fuse (used by the child to detect parent's death); - the ipc channel (used by the parent to get on-exit messages from the child to change its state in the finite-state machine); The problem was that the parent tried to read the message from the pipe right after the fork (and before the child's exit). Usually the pipe was empty at that moment and the parent collected serde's "failed to fill whole buffer" error instead the real message provided by the child. --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 191e8baf57..512825cf71 100644 --- a/src/main.rs +++ b/src/main.rs @@ -154,10 +154,10 @@ fn main_run(args: args::Run) -> ! { drop(from_parent); drop(to_parent); - let msg = from_child.recv(); - let status = waitpid(child, None); + let msg = from_child.recv(); + // Restore termios configuration as planned if let Some(tcattr) = tcattr.as_ref() { tcsetattr(0, TCSADRAIN, tcattr).unwrap(); -- GitLab