Search in sources :

Example 16 with Command

use of com.google.devtools.build.lib.shell.Command 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)16 CommandException (com.google.devtools.build.lib.shell.CommandException)11 CommandResult (com.google.devtools.build.lib.shell.CommandResult)6 IOException (java.io.IOException)6 UserExecException (com.google.devtools.build.lib.actions.UserExecException)4 AbnormalTerminationException (com.google.devtools.build.lib.shell.AbnormalTerminationException)4 TerminationStatus (com.google.devtools.build.lib.shell.TerminationStatus)4 File (java.io.File)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)3 Executor (com.google.devtools.build.lib.actions.Executor)1 FileOutErr (com.google.devtools.build.lib.util.io.FileOutErr)1 Path (com.google.devtools.build.lib.vfs.Path)1 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)1 Path (java.nio.file.Path)1 List (java.util.List)1 Matcher (java.util.regex.Matcher)1