mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-25 04:42:21 +00:00
The goal of this patch is to provide a reliable way to detect when the other end of the PTY is connected, and therefore be able to identify when we can write to the PTY device. This is needed because writing to the PTY device when the other end isn't connected causes the loss of the written bytes. The way to detect the connection on the other end of the PTY is by knowing the other end is disconnected at first with the presence of the EPOLLHUP event. Later on, when the connection happens, EPOLLHUP is not triggered anymore, and that's when we can assume it's okay to write to the PTY main device. It's important to note we had to ensure the file descriptor for the other end was closed, otherwise we would have never seen the EPOLLHUP event. And we did so by removing the "sub" field from the PtyPair structure as it was keeping the associated File opened. Fixes #3170 Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>