Top Description Inners Fields Constructors Methods
org.jruby.util.io

public Class PopenExecutor

extends Object
Class Inheritance
Imports
jnr.constants.platform.Errno, .Fcntl, .OpenFlags, .RLIMIT, jnr.enxio.channels.NativeDeviceChannel, jnr.posix.SpawnAttribute, .SpawnFileAction, org.jcodings.transcode.EConvFlags, org.jruby.Ruby, .RubyArray, .RubyBasicObject, .RubyClass, .RubyFile, .RubyFixnum, .RubyHash, .RubyIO, .RubyNumeric, .RubyProcess, .RubyString, .RubySymbol, org.jruby.api.API, org.jruby.exceptions.RaiseException, org.jruby.ext.fcntl.FcntlLibrary, org.jruby.platform.Platform, org.jruby.runtime.Arity, .Block, .ThreadContext, org.jruby.runtime.builtin.IRubyObject, org.jruby.util.ByteList, .ShellLauncher, .TypeConverter, org.jruby.util.cli.Options, java.io.File, java.util.ArrayList, .Arrays, .Collections, .Comparator, .List, .Map, .Set

Port of MRI's popen+exec logic.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
public static class
private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
private static final byte[]
private Errno
private static final Comparator<PopenExecutor.run_exec_dup2_fd_pair>
private static final Comparator<PopenExecutor.run_exec_dup2_fd_pair>
private static final int
private static final String[]
public static final int
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static String[]
ARGVSTR2ARGV(byte[][] argv_str)

private static void
public static RubyString
public static RubyArray<T extends IRubyObject>
pack-priv static IRubyObject
pack-priv static int
pack-priv static void
pack-priv static void
pack-priv static RubyArray<T extends IRubyObject>
private static void
pack-priv static IRubyObject
checkExecRedirectFd(ThreadContext context, IRubyObject v, boolean iskey)

public static IRubyObject
checkPipeCommand(ThreadContext context, IRubyObject filenameOrCommand)

private static String
private long
DO_SPAWN(ThreadContext context, PopenExecutor.ExecArg eargp, String cmd, String[] args, String[] envp)

pack-priv static int
pack-priv static IRubyObject
pack-priv static void
private static RubyString
execargInit(ThreadContext context, IRubyObject[] argv, IRubyObject optForChdir, boolean accept_shell, PopenExecutor.ExecArg eargp, boolean allow_exc_opt)

public static PopenExecutor.ExecArg
execargNew(ThreadContext context, IRubyObject[] argv, IRubyObject optForChdir, boolean accept_shell, boolean allow_exc_opt)

pack-priv static void
pack-priv static void
pack-priv int
pack-priv static void
private static void
private static RubyString
execGetargs(ThreadContext context, IRubyObject[][] argv_p, boolean accept_shell, IRubyObject[] env_opt)

pack-priv static IRubyObject
handleOptionsCommon(ThreadContext context, PopenExecutor.ExecArg eargp, RubyHash opthash, boolean raise)

pack-priv static boolean
public static boolean

Returns:

true if popen can use native code, false otherwise
nativePopenAvailable
(Ruby
current runtime
runtime
)

Check properties and runtime state to determine whether a native popen is possible.

pack-priv static ChannelFD
open_func(Ruby runtime, RubyIO.Sysopen data)

pack-priv static void
parentRedirectClose(Ruby runtime, int fd)

pack-priv static ChannelFD
public static IRubyObject
pipeOpen(ThreadContext context, IRubyObject prog, String modestr, int fmode, IOEncodable convconfig)

private RubyIO
pipeOpen(ThreadContext context, PopenExecutor.ExecArg eargp, String modestr, int fmode, IOEncodable convconfig)

public static IRubyObject
popen(ThreadContext context, IRubyObject[] argv, RubyClass klass, Block block)

private void
prepareStdioRedirects(ThreadContext context, int[] readPipe, int[] writePipe, PopenExecutor.ExecArg eargp)

pack-priv long
pack-priv long
pack-priv long
private long
pack-priv static int
redirectClearCloexec(ThreadContext context, int oldfd)

pack-priv static int
redirectCloexecDup(ThreadContext context, int oldfd)

pack-priv static void
pack-priv static int
redirectDup(ThreadContext context, int oldfd)

pack-priv static void
redirectDup2(ThreadContext context, PopenExecutor.ExecArg eargp, int oldfd, int newfd)

pack-priv static void
redirectOpen(PopenExecutor.ExecArg eargp, int fd, String pathname, int flags, int perm)

pack-priv static void
pack-priv static int
pack-priv static void
run_exec_dup2_child(ThreadContext context, RubyArray<T extends IRubyObject> ary, PopenExecutor.ExecArg eargp)

Add spawn configuration for duplicating descriptors in the child

pack-priv static void
pack-priv static int
pack-priv static int
run_exec_rlimit(Ruby runtime, RubyArray<T extends IRubyObject> ary, PopenExecutor.ExecArg sargp, String[] errmsg)

pack-priv static int
pack-priv static void
saveEnv(ThreadContext context, Ruby runtime, PopenExecutor.ExecArg sargp)

pack-priv static int
saveRedirectFd(ThreadContext context, int fd, PopenExecutor.ExecArg sargp, String[] errmsg)

private static boolean
searchForMetaChars(RubyString prog)

Search for meta characters in the command, to know whether we should use a shell to launch.

public static RubyFixnum
spawn(ThreadContext context, IRubyObject[] argv)

pack-priv long
public IRubyObject
systemInternal(ThreadContext context, IRubyObject[] argv, String[] errmsg)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait