Skip to content

Child process erroring out instead of blocking on write to stdout on Ruby 3.0? #90

@ClearlyClaire

Description

@ClearlyClaire

I'm trying to port the application I am working on to Ruby 3.0, and one of the issues I have is some dependency “randomly” failing to run commands with large output. I have tracked down the issue to posix-spawn as removing that gem makes the library fall back to Process.spawn which seems to work as expected.

It seems that for some reason, when using posix-spawn on Ruby 3.0, the child process will error out with “Error 11: Resource temporarily unavailable” when filling the pipe's buffer, while on Ruby 2.7, it will simply block as expected.

The following simple code demonstrates the issue:

require 'posix/spawn'

pid, stdin, stdout, stderr = POSIX::Spawn.popen4('yes | head -n 20000000')
stdin.close
puts "output size: #{stdout.read.size}"
puts "stderr: #{stderr.read}"
stdout.close
stderr.close
Process.waitpid pid

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions