Skip to content

Commit

Permalink
lib: don't try to drain the buffer on an unreleased process
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
kevans91 committed Sep 27, 2024
1 parent e680446 commit 7ea8fd7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions lib/porch/process.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion tests/basic_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ for f in "$@" ;do
continue
fi
;;
spawn_*)
spawn_*|resize_*)
spawn=""
;;
esac
Expand Down

0 comments on commit 7ea8fd7

Please sign in to comment.