Avoid ignore_interrupts in safe_fork.

This commit is contained in:
Markus Reiter 2024-07-14 14:32:49 -04:00
parent 44766945fc
commit 447216a960
No known key found for this signature in database
GPG Key ID: 245293B51702655B

View File

@ -75,11 +75,13 @@ module Utils
exit!(true) exit!(true)
end end
ignore_interrupts(quiet: true) do # the child will receive the interrupt and marshal it back pid = T.must(pid)
begin
begin begin
socket = server.accept_nonblock socket = server.accept_nonblock
rescue Errno::EAGAIN, Errno::EWOULDBLOCK, Errno::ECONNABORTED, Errno::EPROTO, Errno::EINTR rescue Errno::EAGAIN, Errno::EWOULDBLOCK, Errno::ECONNABORTED, Errno::EPROTO, Errno::EINTR
retry unless Process.waitpid(T.must(pid), Process::WNOHANG) retry unless Process.waitpid(pid, Process::WNOHANG)
else else
socket.send_io(write) socket.send_io(write)
socket.close socket.close
@ -87,12 +89,14 @@ module Utils
write.close write.close
data = read.read data = read.read
read.close read.close
Process.wait(T.must(pid)) unless socket.nil? Process.waitpid(pid) unless socket.nil?
rescue Interrupt
Process.waitpid(pid)
end
# 130 is the exit status for a process interrupted via Ctrl-C. # 130 is the exit status for a process interrupted via Ctrl-C.
# We handle it here because of the possibility of an interrupted process terminating
# without writing its Interrupt exception to the error pipe.
raise Interrupt if $CHILD_STATUS.exitstatus == 130 raise Interrupt if $CHILD_STATUS.exitstatus == 130
raise Interrupt if $CHILD_STATUS.termsig == Signal.list["INT"]
if data.present? if data.present?
error_hash = JSON.parse(T.must(data.lines.first)) error_hash = JSON.parse(T.must(data.lines.first))
@ -107,4 +111,3 @@ module Utils
end end
end end
end end
end