Skip to content

Commit 03a10b9

Browse files
committed
Wrap all stdio closing in pcalls
1 parent e6b7c21 commit 03a10b9

File tree

2 files changed

+35
-14
lines changed

2 files changed

+35
-14
lines changed

fnl/conjure/remote/stdio.fnl

+7-7
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@
4949

5050
(fn destroy []
5151
;; https://teukka.tech/vimloop.html
52-
(stdout:read_stop)
53-
(stderr:read_stop)
54-
(stdout:close)
55-
(stderr:close)
56-
(stdin:close)
52+
(pcall #(stdout:read_stop))
53+
(pcall #(stderr:read_stop))
54+
(pcall #(stdout:close))
55+
(pcall #(stderr:close))
56+
(pcall #(stdin:close))
5757
(when repl.handle
58-
(uv.process_kill repl.handle)
59-
(repl.handle:close))
58+
(pcall #(uv.process_kill repl.handle))
59+
(pcall #(repl.handle:close)))
6060
nil)
6161

6262
(fn on-exit [code signal]

lua/conjure/remote/stdio.lua

+28-7
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,35 @@ do
108108
local stderr = uv.new_pipe(false)
109109
local repl = {current = nil, queue = {}}
110110
local function destroy()
111-
stdout:read_stop()
112-
stderr:read_stop()
113-
stdout:close()
114-
stderr:close()
115-
stdin:close()
111+
local function _2_()
112+
return stdout:read_stop()
113+
end
114+
pcall(_2_)
115+
local function _3_()
116+
return stderr:read_stop()
117+
end
118+
pcall(_3_)
119+
local function _4_()
120+
return stdout:close()
121+
end
122+
pcall(_4_)
123+
local function _5_()
124+
return stderr:close()
125+
end
126+
pcall(_5_)
127+
local function _6_()
128+
return stdin:close()
129+
end
130+
pcall(_6_)
116131
if repl.handle then
117-
uv.process_kill(repl.handle)
118-
do end (repl.handle):close()
132+
local function _7_()
133+
return uv.process_kill(repl.handle)
134+
end
135+
pcall(_7_)
136+
local function _8_()
137+
return (repl.handle):close()
138+
end
139+
pcall(_8_)
119140
end
120141
return nil
121142
end

0 commit comments

Comments
 (0)