public Process run(String... args) throws IOException { File cwd = handler.getCurrentWorkingDirectory(); return Runtime.getRuntime().exec(args, handler.getEnv(), cwd); }
public int getpid() { return handler.getPID(); } ThreadLocal<Integer> pwIndex = new ThreadLocal<Integer>() {
public long read(int fd, byte[] buf, long n) { handler.unimplementedError("read"); return -1; } public long write(int fd, byte[] buf, long n) {
public int setenv(String envName, String envValue, int overwrite) { Map<String, String> env = helper.getEnv(); if (envName.contains("=")) { handler.error(EINVAL, "setenv", envName); return -1; } // POSIX specified. Existence is success if overwrite is 0. if (overwrite == 0 && env.containsKey(envName)) return 0; env.put(envName, envValue); return 0; }
HANDLE output, HANDLE error, String[] envp) { if (command == null && program == null) { handler.error(EFAULT, callingMethodName, "no command or program specified"); return null; byte[] cwd = WindowsHelpers.toWString(WindowsHelpers.escapePath(handler.getCurrentWorkingDirectory().toString()) +"\\"); ByteBuffer commandW = ByteBuffer.wrap(WindowsHelpers.toWString(command)); boolean returnValue = wlibc().CreateProcessW(programW, commandW,
public boolean isExecutable() { handler.warn(WARNING_ID.DUMMY_VALUE_USED, "executable? does not in this environment and will return a dummy value", "executable"); return true; }
public int runAndWait(String... args) throws IOException, InterruptedException { return runAndWait(handler.getOutputStream(), errorStream, args); }
public int runAndWait(OutputStream output, OutputStream error, String... args) throws IOException, InterruptedException { Process process = run(args); handleStreams(process, handler.getInputStream(), output, error); return process.waitFor(); }
public int runAndWait(OutputStream output, String... args) throws IOException, InterruptedException { return runAndWait(output, handler.getErrorStream(), args); }
static POSIX loadPOSIX(POSIXHandler handler, boolean useNativePOSIX) { POSIX posix = null; if (useNativePOSIX) { try { posix = loadNativePOSIX(handler); posix = posix != null ? new CheckedPOSIX(posix, handler) : null; // ENEBO: Should printing be done through a handler+log method? if (handler.isVerbose()) { if (posix != null) { System.err.println("Successfully loaded native POSIX impl."); } else { System.err.println("Failed to load native POSIX impl; falling back on Java impl. Unsupported OS."); } } } catch (Throwable t) { if (handler.isVerbose()) { System.err.println("Failed to load native POSIX impl; falling back on Java impl. Stacktrace follows."); t.printStackTrace(); } } } if (posix == null) { posix = getJavaPOSIX(handler); } return posix; }
public int setenv(String envName, String envValue, int overwrite) { Map<String, String> env = helper.getEnv(); if (envName.contains("=")) { handler.error(EINVAL, "setenv", envName); return -1; } // POSIX specified. Existence is success if overwrite is 0. if (overwrite == 0 && env.containsKey(envName)) return 0; env.put(envName, envValue); return 0; }
HANDLE output, HANDLE error, String[] envp) { if (command == null && program == null) { handler.error(EFAULT, callingMethodName, "no command or program specified"); return null; byte[] cwd = WindowsHelpers.toWString(WindowsHelpers.escapePath(handler.getCurrentWorkingDirectory().toString()) +"\\"); ByteBuffer commandW = ByteBuffer.wrap(WindowsHelpers.toWString(command)); boolean returnValue = wlibc().CreateProcessW(programW, commandW,
public boolean isExecutableReal() { handler.warn(WARNING_ID.DUMMY_VALUE_USED, "executable_real? does not work in this environmnt and will return a dummy value", "executable_real"); return true; }
public int runAndWait(String... args) throws IOException, InterruptedException { return runAndWait(handler.getOutputStream(), errorStream, args); }
public int runAndWait(OutputStream output, OutputStream error, String... args) throws IOException, InterruptedException { Process process = run(args); handleStreams(process, handler.getInputStream(), output, error); return process.waitFor(); }
public int runAndWait(OutputStream output, String... args) throws IOException, InterruptedException { return runAndWait(output, handler.getErrorStream(), args); }
static POSIX loadPOSIX(POSIXHandler handler, boolean useNativePOSIX) { POSIX posix = null; if (useNativePOSIX) { try { posix = loadNativePOSIX(handler); posix = posix != null ? new CheckedPOSIX(posix, handler) : null; // ENEBO: Should printing be done through a handler+log method? if (handler.isVerbose()) { if (posix != null) { System.err.println("Successfully loaded native POSIX impl."); } else { System.err.println("Failed to load native POSIX impl; falling back on Java impl. Unsupported OS."); } } } catch (Throwable t) { if (handler.isVerbose()) { System.err.println("Failed to load native POSIX impl; falling back on Java impl. Stacktrace follows."); t.printStackTrace(); } } } if (posix == null) { posix = getJavaPOSIX(handler); } return posix; }
public int setenv(String envName, String envValue, int overwrite) { Map<String, String> env = helper.getEnv(); if (envName.contains("=")) { handler.error(EINVAL, "setenv", envName); return -1; } // POSIX specified. Existence is success if overwrite is 0. if (overwrite == 0 && env.containsKey(envName)) return 0; env.put(envName, envValue); return 0; }
public long write(int fd, ByteBuffer buf, long n) { handler.unimplementedError("write"); return -1; } public long pread(int fd, byte[] buf, long n, long offset) {
public Process run(String... args) throws IOException { File cwd = handler.getCurrentWorkingDirectory(); return Runtime.getRuntime().exec(args, handler.getEnv(), cwd); }