Skip to content

Commit 4fa3719

Browse files
Add writer.close_on_finalize = false for signal pipe (#16167)
1 parent 847c0ce commit 4fa3719

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/crystal/system/unix/signal.cr

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ module Crystal::System::Signal
1212

1313
alias Handler = ::Signal ->
1414

15-
@@pipe = IO.pipe(read_blocking: false, write_blocking: true)
15+
@@pipe : {IO::FileDescriptor, IO::FileDescriptor} = begin
16+
IO.pipe(read_blocking: false, write_blocking: true).tap do |reader, writer|
17+
# This avoids accidentally closing the pipe from the interpreter.
18+
# See https://github.com/crystal-lang/crystal/issues/16040 for details.
19+
writer.close_on_finalize = false
20+
end
21+
end
22+
1623
@@handlers = {} of ::Signal => Handler
1724
@@sigset = Sigset.new
1825
class_property child_handler : Handler?

0 commit comments

Comments
 (0)