private void prepareStdioRedirects(Ruby runtime, int[] readPipe, int[] writePipe, ExecArg eargp) { // We insert these redirects directly into fd_dup2 so that chained redirection can be // validated and set up properly by the execargFixup logic. // The closes do not appear to be part of MRI's logic (they close the fd before exec/spawn), // so rather than using execargAddopt we do them directly here. if (readPipe != null) { // dup our read pipe's write end into stdout int readPipeWriteFD = readPipe[1]; eargp.fd_dup2 = checkExecRedirect1(runtime, eargp.fd_dup2, runtime.newFixnum(1), runtime.newFixnum(readPipeWriteFD)); // close the other end of the pipe in the child int readPipeReadFD = readPipe[0]; eargp.fileActions.add(SpawnFileAction.close(readPipeReadFD)); } if (writePipe != null) { // dup our write pipe's read end into stdin int writePipeReadFD = writePipe[0]; eargp.fd_dup2 = checkExecRedirect1(runtime, eargp.fd_dup2, runtime.newFixnum(0), runtime.newFixnum(writePipeReadFD)); // close the other end of the pipe in the child int writePipeWriteFD = writePipe[1]; eargp.fileActions.add(SpawnFileAction.close(writePipeWriteFD)); } }
private void prepareStdioRedirects(Ruby runtime, int[] readPipe, int[] writePipe, ExecArg eargp) { // We insert these redirects directly into fd_dup2 so that chained redirection can be // validated and set up properly by the execargFixup logic. // The closes do not appear to be part of MRI's logic (they close the fd before exec/spawn), // so rather than using execargAddopt we do them directly here. if (readPipe != null) { // dup our read pipe's write end into stdout int readPipeWriteFD = readPipe[1]; eargp.fd_dup2 = checkExecRedirect1(runtime, eargp.fd_dup2, runtime.newFixnum(1), runtime.newFixnum(readPipeWriteFD)); // close the other end of the pipe in the child int readPipeReadFD = readPipe[0]; eargp.fileActions.add(SpawnFileAction.close(readPipeReadFD)); } if (writePipe != null) { // dup our write pipe's read end into stdin int writePipeReadFD = writePipe[0]; eargp.fd_dup2 = checkExecRedirect1(runtime, eargp.fd_dup2, runtime.newFixnum(0), runtime.newFixnum(writePipeReadFD)); // close the other end of the pipe in the child int writePipeWriteFD = writePipe[1]; eargp.fileActions.add(SpawnFileAction.close(writePipeWriteFD)); } }
private static void checkExecRedirectDefault(Ruby runtime, IRubyObject key, IRubyObject val, ExecArg eargp) { IRubyObject tmp; IRubyObject param; tmp = val; val = TypeConverter.ioCheckIO(runtime, tmp); if (!val.isNil()) { val = checkExecRedirectFd(runtime, val, false); param = val; eargp.fd_dup2 = checkExecRedirect1(runtime, eargp.fd_dup2, key, param); } throw runtime.newArgumentError("wrong exec redirect action"); }
private static void checkExecRedirectDefault(Ruby runtime, IRubyObject key, IRubyObject val, ExecArg eargp) { IRubyObject tmp; IRubyObject param; tmp = val; val = TypeConverter.ioCheckIO(runtime, tmp); if (!val.isNil()) { val = checkExecRedirectFd(runtime, val, false); param = val; eargp.fd_dup2 = checkExecRedirect1(runtime, eargp.fd_dup2, key, param); } throw runtime.newArgumentError("wrong exec redirect action"); }
if (id.equals("close")) { param = context.nil; eargp.fd_close = checkExecRedirect1(runtime, eargp.fd_close, key, param); eargp.fd_dup2 = checkExecRedirect1(runtime, eargp.fd_dup2, key, param); eargp.fd_dup2 = checkExecRedirect1(runtime, eargp.fd_dup2, key, param); eargp.fd_dup2 = checkExecRedirect1(runtime, eargp.fd_dup2, key, param); if (val instanceof RubyFixnum) { param = val; eargp.fd_dup2 = checkExecRedirect1(runtime, eargp.fd_dup2, key, param); break; path.toString().equals("child")) { param = checkExecRedirectFd(runtime, ((RubyArray)val).eltOk(1), false); eargp.fd_dup2_child = checkExecRedirect1(runtime, eargp.fd_dup2_child, key, param); flags, perm); eargp.fd_open = checkExecRedirect1(runtime, eargp.fd_open, key, param); flags, perm); eargp.fd_open = checkExecRedirect1(runtime, eargp.fd_open, key, param); break;
if (id.equals("close")) { param = context.nil; eargp.fd_close = checkExecRedirect1(runtime, eargp.fd_close, key, param); eargp.fd_dup2 = checkExecRedirect1(runtime, eargp.fd_dup2, key, param); eargp.fd_dup2 = checkExecRedirect1(runtime, eargp.fd_dup2, key, param); eargp.fd_dup2 = checkExecRedirect1(runtime, eargp.fd_dup2, key, param); if (val instanceof RubyFixnum) { param = val; eargp.fd_dup2 = checkExecRedirect1(runtime, eargp.fd_dup2, key, param); break; path.toString().equals("child")) { param = checkExecRedirectFd(runtime, ((RubyArray)val).eltOk(1), false); eargp.fd_dup2_child = checkExecRedirect1(runtime, eargp.fd_dup2_child, key, param); flags, perm); eargp.fd_open = checkExecRedirect1(runtime, eargp.fd_open, key, param); flags, perm); eargp.fd_open = checkExecRedirect1(runtime, eargp.fd_open, key, param); break;