Skip to content

system and spawn raise 'wrong exec redirect action' when redirecting given out: tempfile or err: tempfile #4457

@doudou

Description

@doudou

Environment

jruby 9.1.7.0 (2.3.1) 2017-01-11 68056ae Java HotSpot(TM) 64-Bit Server VM 25.121-b13 on 1.8.0_121-b13 +jit [linux-x86_64]

Ubuntu 16.04, jruby installed with rbenv

Expected Behavior

MRI supports redirecting the standard output or standard error of a subprocess to an already opened IO with out: io, err: io. This works if io is a tempfile.

require 'tempfile'
Tempfile.open('jruby') do |io|
    begin
        puts "SPAWN"
        Process.waitpid spawn('ls', out: io)
    rescue Exception => e
        puts e
    end
    begin
        puts "SYSTEM"
        system('ls', out: io)
    rescue Exception => e
        puts e
    end
    begin
        puts "EXEC"
        exec('ls', out: io)
    rescue Exception => e
        puts e
    end
end

Actual Behavior

JRuby raises "wrong exec redirect action". Replacing the tempfile by a plain File works.

Looking at the actual code it does seem that IO and File should be supported. Maybe an else is missing here ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions