Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
doudou opened this issue Jan 25, 2017 · 1 comment
Milestone

Comments

@doudou
Copy link

doudou commented Jan 25, 2017

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 ?

@doudou doudou changed the title system and spawn raise 'wrong exec redirect action' when redirecting given out: io or err: io system and spawn raise 'wrong exec redirect action' when redirecting given out: tempfile or err: tempfile Jan 25, 2017
@enebo enebo closed this as completed in f792cb2 Jan 26, 2017
@enebo
Copy link
Member

enebo commented Jan 26, 2017

@doudou indeed we were just missing an else (although I used a break to keep the logic a little closer to MRI). exec is still not properly supporting :out but you added an issue for that separately...

@enebo enebo added this to the JRuby 9.1.8.0 milestone Jan 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants