Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions lua/pi/runner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,9 @@ function M.finish(session)
return
end

local stdin = session.process._state and session.process._state.stdin
if stdin then
pcall(function()
stdin:close()
end)
elseif not session.process:is_closing() then
local ok, err = pcall(session.process.write, session.process, nil)
if not ok then
-- fallback: kill if write fails (process already dead)
pcall(session.process.kill, session.process, 15)
end
end
Expand Down
18 changes: 6 additions & 12 deletions tests/test_pi_commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ local function mock_system()
_G.__pi_test_system.on_exit = on_exit
return {
write = function(_, data)
table.insert(_G.__pi_test_system.writes, data)
if data == nil then
_G.__pi_test_system.stdin_closed = true
_G.__pi_test_system.closing = true
else
table.insert(_G.__pi_test_system.writes, data)
end
end,
kill = function(_, signal)
_G.__pi_test_system.killed = signal
Expand All @@ -75,17 +80,6 @@ local function mock_system()
is_closing = function()
return _G.__pi_test_system.closing
end,
_state = {
stdin = {
close = function()
_G.__pi_test_system.stdin_closed = true
_G.__pi_test_system.closing = true
end,
flush = function()
-- No-op in tests
end,
},
},
}
end
]])
Expand Down
Loading