From 7ea8fd7b6376a146a39ee4836b9bdb086719d925 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Thu, 26 Sep 2024 23:21:35 -0500 Subject: [PATCH] lib: don't try to drain the buffer on an unreleased process Depending on where we're at in the closing of the process, we could easily catch a SIGPIPE here if we, e.g., sent a SIGINT and killed the process. Coincidentally, stop spawning a cat(1) process that we won't be using for the resize tests. The implicit close from immediately spawning off the shell script tripped over this drain error intermittently. Signed-off-by: Kyle Evans --- lib/porch/process.lua | 10 ++++++++-- tests/basic_test.sh | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/porch/process.lua b/lib/porch/process.lua index 5add0d3..268fc16 100644 --- a/lib/porch/process.lua +++ b/lib/porch/process.lua @@ -204,9 +204,15 @@ function Process:write(data, cfg) end function Process:close() local function procdrain() - if not self.buffer.eof then - self.buffer:refill() + -- It's imperative that we not try to drain a process that + -- hasn't been started yet; there won't be anything pending + -- anyways, and trying to release it may end up catching us a + -- SIGPIPE. + if self.buffer.eof or not self._process:released() then + return end + + self.buffer:refill() end assert(self._process:close(procdrain)) diff --git a/tests/basic_test.sh b/tests/basic_test.sh index e8747b7..3bb0a34 100644 --- a/tests/basic_test.sh +++ b/tests/basic_test.sh @@ -69,7 +69,7 @@ for f in "$@" ;do continue fi ;; - spawn_*) + spawn_*|resize_*) spawn="" ;; esac