childprocess icon indicating copy to clipboard operation
childprocess copied to clipboard

Ruby 3.0 support

Open voxik opened this issue 3 years ago • 9 comments

There is test failure testing on Ruby 3.0:

  1) ChildProcess can write to stdin interactively if duplex = true
     Failure/Error: raise msg
     
     RuntimeError:
       timed out after 10 seconds:
       expected "hello\ncat: -: Resource temporarily unavailable\n" to match /\Ahello\r?\n\z/m
       Diff:
       @@ -1,2 +1,3 @@
       -/\Ahello\r?\n\z/m
       +hello
       +cat: -: Resource temporarily unavailable
       
     # ./spec/spec_helper.rb:197:in `wait_until'
     # ./spec/io_spec.rb:121:in `block (2 levels) in <top (required)>'

Any chance to get this fixed please?

voxik avatar Feb 03 '21 09:02 voxik

It seems that the problem might be some race condition, since this works:

$ rspec ./spec/io_spec.rb
..........

Finished in 0.79139 seconds (files took 0.07509 seconds to load)
10 examples, 0 failures

voxik avatar Feb 03 '21 09:02 voxik

Ah, forgot to include the CHILDPROCESS_POSIX_SPAWN=true, so it doesn't work indeed.

voxik avatar Feb 03 '21 09:02 voxik

This was the last successful build:

https://travis-ci.org/github/enkessler/childprocess/jobs/687662868

and this is where the issue first appeared:

https://travis-ci.org/github/enkessler/childprocess/jobs/698756797

voxik avatar Feb 03 '21 11:02 voxik

So the cat: -: Resource temporarily unavailable is reported from here:

https://github.com/enkessler/childprocess/blob/c6260739e86c1cabd9baebd76f2058eea2b1ae16/lib/childprocess/unix/posix_spawn_process.rb#L51-L58

called from here:

https://github.com/enkessler/childprocess/blob/c6260739e86c1cabd9baebd76f2058eea2b1ae16/spec/io_spec.rb#L114-L116

Checking what was changed in Ruby, this is susceptible commit:

https://github.com/ruby/ruby/commit/0e3b0fcdba70cf96a8e0654eb8f50aacb8024bd4

But that might be completely false lead :innocent:

voxik avatar Feb 03 '21 11:02 voxik

This seems to be the root cause, the change from RUBY_PIPE_NONBLOCK_DEFAULT, which was 0, to O_NONBLOCK. I have locally replaced the O_NONBLOCK by 0 and the test suite passes.

Unfortunately, other test case fails then:

  1) ChildProcess lets a detached child live on
     Failure/Error: expect(alive?(c_pid)).to be true
     
       expected true
            got false
     # ./spec/childprocess_spec.rb:214:in `block (2 levels) in <top (required)>'

voxik avatar Feb 03 '21 13:02 voxik

I have reported this against Ruby:

https://bugs.ruby-lang.org/issues/17607

voxik avatar Feb 03 '21 14:02 voxik

I wonder if https://github.com/enkessler/childprocess/issues/172 / https://github.com/enkessler/childprocess/pull/175 might solve this. At least CHILDPROCESS_UNSET=should-be-unset bundle exec rake passes for me on that PR with Ruby 3.0.0.

eregon avatar Feb 16 '21 12:02 eregon

Confirmed that https://github.com/enkessler/childprocess/pull/175#issuecomment-779820190 actually fixes the CI on ruby-head (the only ruby-head CI failing is then due to installing FFI, which is unrelated and no longer needed with that PR).

eregon avatar Feb 16 '21 12:02 eregon

Thx, the test suite passes with #175. Nevertheless, I'd still like to also understand the reasons why it started to fail, although it will have smaller priority :innocent:

voxik avatar Feb 18 '21 11:02 voxik