Search in sources :

Example 6 with CommandResult

use of com.google.devtools.build.lib.shell.CommandResult in project bazel by bazelbuild.

the class DarwinSandboxedStrategy method getConfStr.

/**
   * Returns the value of a POSIX or X/Open system configuration variable.
   */
private static String getConfStr(String confVar) throws IOException {
    String[] commandArr = new String[2];
    commandArr[0] = "getconf";
    commandArr[1] = confVar;
    Command cmd = new Command(commandArr);
    CommandResult res;
    try {
        res = cmd.execute();
    } catch (CommandException e) {
        throw new IOException("getconf failed", e);
    }
    return new String(res.getStdout(), UTF_8).trim();
}
Also used : Command(com.google.devtools.build.lib.shell.Command) CommandException(com.google.devtools.build.lib.shell.CommandException) IOException(java.io.IOException) CommandResult(com.google.devtools.build.lib.shell.CommandResult)

Aggregations

Command (com.google.devtools.build.lib.shell.Command)6 CommandResult (com.google.devtools.build.lib.shell.CommandResult)6 CommandException (com.google.devtools.build.lib.shell.CommandException)4 IOException (java.io.IOException)4 UserExecException (com.google.devtools.build.lib.actions.UserExecException)2 AbnormalTerminationException (com.google.devtools.build.lib.shell.AbnormalTerminationException)2 TerminationStatus (com.google.devtools.build.lib.shell.TerminationStatus)2 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1