From: Eric Wong Date: 2018-04-21T03:25:16+00:00 Subject: [ruby-core:86634] Re: [Ruby trunk Bug#14681] `syswrite': stream closed in another thread (IOError) samuel@oriontransfer.org wrote: > Bug #14681: `syswrite': stream closed in another thread (IOError) > https://bugs.ruby-lang.org/issues/14681 There's two bugs, here, I think. I made r63216 because it became obvious to me with the timeline shown in the commit message: https://80x24.org/spew/20180421024614.7362-1-e@80x24.org/raw However, I have a work-in-progress fix which probably requires API rework for rb_thread_io_blocking_region: https://80x24.org/spew/20180421021502.31552-1-e@80x24.org/ Note: the /* TODO: check func() */ in rb_thread_io_blocking_region But that WIP patch is broken... I think we need to replace rb_thread_io_blocking_region to permanently fix your problem. My change to check "val != Qundef" is insufficient and wrong. But I don't know how reasonable close notifications can be with APIs like IO.copy_stream and IO.select which work on multiple IOs, even... However, you can work around the problem simply: > 100.times.collect do > Thread.new do > input, output = IO.pipe > > worker = Thread.new do > sleep(0.1) > output.syswrite('.') > end > > input.read(1) > > input.close > output.close > worker.join You should be able to rearrange the order of the last two calls so worker.join happens before output.close: worker.join output.close Thats should avoid the problem described in https://80x24.org/spew/20180421021502.31552-1-e@80x24.org/ > end > end.each(&:join) > ``` Unsubscribe: