IRunUtil
public
interface
IRunUtil
| com.android.tradefed.util.IRunUtil |
用于运行定时操作和系统命令的接口。
摘要
嵌套类 | |
|---|---|
interface |
IRunUtil.IRunnableResult
用于异步执行返回布尔值状态的操作的接口。 |
公共方法 | |
|---|---|
abstract
void
|
allowInterrupt(boolean allow)
允许/禁止对当前线程运行中断。 |
abstract
void
|
interrupt(Thread thread, String message, ErrorIdentifier errorId)
中断给定线程上正在进行/即将进行的运行操作。 |
abstract
void
|
interrupt(Thread thread, String message)
中断给定线程上正在进行/即将进行的运行操作。 |
abstract
boolean
|
isInterruptAllowed()
提供 RunUtil 的中断状态。 |
abstract
Process
|
runCmdInBackground(Redirect redirect,
另一种 |
abstract
Process
|
runCmdInBackground(
另一种 |
abstract
Process
|
runCmdInBackground(
使用 |
abstract
Process
|
runCmdInBackground(String... command)
用于异步执行系统命令的辅助方法。 |
abstract
Process
|
runCmdInBackground(Redirect redirect, String... command)
用于异步执行系统命令的辅助方法。 |
abstract
boolean
|
runEscalatingTimedRetry(long opTimeout, long initialPollInterval, long maxPollInterval, long maxTime, IRunUtil.IRunnableResult runnable)
阻塞并多次执行操作,直到操作成功为止。 |
abstract
boolean
|
runFixedTimedRetry(long opTimeout, long pollInterval, long maxTime, IRunUtil.IRunnableResult runnable)
阻塞并多次执行操作,直到操作成功为止。 |
abstract
boolean
|
runFixedTimedRetryWithOutputMonitor(long opTimeout, long idleOutputTimeout, long pollInterval, long maxTime, IRunUtil.IRunnableResult runnable)
阻塞并多次执行操作,直到操作成功为止。 |
abstract
CommandStatus
|
runTimed(long timeout, IRunUtil.IRunnableResult runnable, boolean logErrors)
阻塞并执行操作,如果操作耗时超过指定时间,则中止。 |
abstract
CommandResult
|
runTimedCmd(long timeout, OutputStream stdout, OutputStream stderr, String... command)
用于执行系统命令的辅助方法,如果命令耗时超过指定时间,则会中止,并将输出重定向到文件(如果指定)。 |
abstract
CommandResult
|
runTimedCmd(long timeout, String... command)
用于执行系统命令的辅助方法,如果执行时间超过指定时间,则会中止。 |
abstract
CommandResult
|
runTimedCmdRetry(long timeout, long retryInterval, int attempts, String... command)
用于执行系统命令的辅助方法,如果执行时间超过指定时间,则会中止。 |
abstract
CommandResult
|
runTimedCmdRetryWithOutputMonitor(long timeout, long idleOutputTimeout, long retryInterval, int attempts, String... command)
用于执行系统命令的辅助方法,如果执行时间超过指定时间,则会中止。 |
abstract
CommandResult
|
runTimedCmdSilently(long timeout, String... command)
用于执行系统命令的辅助方法,如果执行时间超过指定时间,则会中止。 |
abstract
CommandResult
|
runTimedCmdSilentlyRetry(long timeout, long retryInterval, int attempts, String... command)
用于执行系统命令的辅助方法,如果执行时间超过指定时间,则会中止。 |
abstract
CommandResult
|
runTimedCmdWithInput(long timeout, String input, File stdoutFile, File stderrFile, String... command)
用于执行系统命令的辅助方法,如果命令执行时间超过指定时间,则会中止,并将输出重定向到文件(如果指定)。 |
abstract
CommandResult
|
runTimedCmdWithInput(long timeout, String input, String... command)
用于执行需要 stdin 输入的系统命令的辅助方法,如果执行时间超过指定时间,则会中止。 |
abstract
CommandResult
|
runTimedCmdWithInput(long timeout, String input,
用于执行需要 stdin 输入的系统命令的辅助方法,如果执行时间超过指定时间,则会中止。 |
abstract
CommandResult
|
runTimedCmdWithInputRedirect(long timeout, File inputRedirect, String... command)
用于执行需要从文件重定向 Stdin 的系统命令的辅助方法,如果执行时间超过指定时间,则会中止。 |
abstract
CommandResult
|
runTimedCmdWithOutputMonitor(long timeout, long idleOutputTimeout, OutputStream stdout, OutputStream stderr, String... command)
用于执行系统命令的辅助方法,如果命令执行时间超过指定时间,则会中止,并将输出重定向到文件(如果指定)。 |
abstract
CommandResult
|
runTimedCmdWithOutputMonitor(long timeout, long idleOutputTimeout, String... command)
用于执行系统命令的辅助方法,如果执行时间超过指定时间,则会中止。 |
abstract
boolean
|
runTimedRetry(long opTimeout, long pollInterval, int attempts, IRunUtil.IRunnableResult runnable)
阻塞并多次执行操作,直到操作成功为止。 |
abstract
boolean
|
runTimedRetryWithOutputMonitor(long opTimeout, long idleOutputTimeout, long pollInterval, int attempts, IRunUtil.IRunnableResult runnable)
阻塞并多次执行操作,直到操作成功为止。 |
abstract
CommandStatus
|
runTimedWithOutputMonitor(long timeout, long idleOutputTimeout, IRunUtil.IRunnableResult runnable, boolean logErrors)
阻塞并执行操作,如果操作耗时超过指定时间,则中止。 |
abstract
void
|
setEnvVariable(String key, String value)
设置要在运行系统命令时使用的环境变量。 |
abstract
void
|
setEnvVariablePriority(IRunUtil.EnvPriority priority)
确定在创建进程时,取消设置环境变量的优先级是否高于设置环境变量。 |
abstract
void
|
setInterruptibleInFuture(Thread thread, long timeMs)
在等待一段时间后设为可中断。 |
abstract
void
|
setLinuxInterruptProcess(boolean interrupt)
允许在通过 #runTimed 方法运行的进程达到超时时使用 Linux“kill”中断。 |
abstract
void
|
setRedirectStderrToStdout(boolean redirect)
在运行系统命令时,将标准错误流设置为重定向到标准输出流。 |
abstract
void
|
setWorkingDir(File dir)
设置系统命令的工作目录。 |
abstract
void
|
sleep(long time)
用于指定时间休眠的辅助方法,会忽略任何异常。 |
abstract
void
|
unsetEnvVariable(String key)
取消设置环境变量,以便系统命令在没有此环境变量的情况下运行。 |
公共方法
allowInterrupt
public abstract void allowInterrupt (boolean allow)
允许/禁止对当前线程进行运行中断。如果允许,可以通过 interrupt(Thread, String) 方法从其他线程中中断当前线程的运行操作。
| 参数 | |
|---|---|
allow |
boolean:是否允许对当前线程进行运行中断。 |
中断
public abstract void interrupt (Thread thread,
String message,
ErrorIdentifier errorId)中断给定线程上正在进行/即将进行的运行操作。对给定线程运行的操作将抛出 RunInterruptedException。
| 参数 | |
|---|---|
message |
String:RunInterruptedException 的消息。 |
errorId |
ErrorIdentifier:表示中断原因(如果已知)。 |
中断
public abstract void interrupt (Thread thread,
String message)中断给定线程上正在进行/即将进行的运行操作。对给定线程运行的操作将抛出 RunInterruptedException。
| 参数 | |
|---|---|
message |
String:RunInterruptedException 的消息。 |
isInterruptAllowed
public abstract boolean isInterruptAllowed ()
提供 RunUtil 的中断状态。
| 返回 | |
|---|---|
boolean |
如果可以中断运行,则为 true;否则为 false。 |
runCmdInBackground
public abstract Process runCmdInBackground (Redirect redirect,
command) 另一种 runCmdInBackground(String) 方法,接受 ERROR(/List) 格式的命令参数。
| 参数 | |
|---|---|
redirect |
Redirect:要应用于 ProcessBuilder 的 ERROR(/Redirect)。 |
command |
:包含指定系统命令和可选的执行参数的 ERROR(/List) |
| 返回 | |
|---|---|
Process |
所执行命令的 Process |
| 抛出 | |
|---|---|
|
如果命令运行失败 |
runCmdInBackground
public abstract Process runCmdInBackground (command)
另一种 runCmdInBackground(String) 方法,接受 ERROR(/List) 格式的命令参数。
| 参数 | |
|---|---|
command |
:包含指定系统命令和可选的执行参数的 ERROR(/List) |
| 返回 | |
|---|---|
Process |
所执行命令的 Process |
| 抛出 | |
|---|---|
|
如果命令运行失败 |
runCmdInBackground
public abstract Process runCmdInBackground (command, OutputStream output)
使用 ERROR(/OutputStream) 运行命令会记录命令的输出。
stdout 和 stderr 会合并在一起。
| 参数 | |
|---|---|
command |
:要运行的命令 |
output |
OutputStream:用于保存输出的 OutputStream |
| 返回 | |
|---|---|
Process |
运行该命令的 Process |
| 抛出 | |
|---|---|
|
IOException |
runCmdInBackground
public abstract Process runCmdInBackground (String... command)
用于异步执行系统命令的辅助方法。
在启动命令后立即返回。
| 参数 | |
|---|---|
command |
String:指定的系统命令以及可选的 exec 参数 |
| 返回 | |
|---|---|
Process |
所执行命令的 Process |
| 抛出 | |
|---|---|
|
如果命令运行失败 |
runCmdInBackground
public abstract Process runCmdInBackground (Redirect redirect,
String... command)用于异步执行系统命令的辅助方法。
在启动命令后立即返回。
| 参数 | |
|---|---|
redirect |
Redirect:要应用于 ProcessBuilder 的 ERROR(/Redirect)。 |
command |
String:指定的系统命令以及可选的 exec 参数 |
| 返回 | |
|---|---|
Process |
所执行命令的 Process |
| 抛出 | |
|---|---|
|
如果命令运行失败 |
runEscalatingTimedRetry
public abstract boolean runEscalatingTimedRetry (long opTimeout,
long initialPollInterval,
long maxPollInterval,
long maxTime,
IRunUtil.IRunnableResult runnable)阻塞并多次执行操作,直到操作成功为止。
以指数方式增加操作尝试之间的等待时间。此参数适用于执行诸如轮询服务器之类的操作时,以便在服务器暂时宕机时有时间恢复。
| 参数 | |
|---|---|
opTimeout |
long:单次操作尝试的等待时长上限(以毫秒为单位) |
initialPollInterval |
long:操作尝试之间的初始等待时间 |
maxPollInterval |
long:操作尝试之间的最长等待时间 |
maxTime |
long:继续尝试执行操作的总大致上限时间 |
runnable |
IRunUtil.IRunnableResult:IRunUtil.IRunnableResult 要执行 |
| 返回 | |
|---|---|
boolean |
如果操作在 maxTime 过期之前成功完成,则返回 true |
runFixedTimedRetry
public abstract boolean runFixedTimedRetry (long opTimeout,
long pollInterval,
long maxTime,
IRunUtil.IRunnableResult runnable)阻塞并多次执行操作,直到操作成功为止。
| 参数 | |
|---|---|
opTimeout |
long:单次操作尝试的等待时长上限(以毫秒为单位) |
pollInterval |
long:操作尝试之间的初始等待时间 |
maxTime |
long:继续尝试执行操作的大致总时长上限 |
runnable |
IRunUtil.IRunnableResult:IRunUtil.IRunnableResult 要执行 |
| 返回 | |
|---|---|
boolean |
如果操作在 maxTime 过期之前成功完成,则返回 true |
runFixedTimedRetryWithOutputMonitor
public abstract boolean runFixedTimedRetryWithOutputMonitor (long opTimeout,
long idleOutputTimeout,
long pollInterval,
long maxTime,
IRunUtil.IRunnableResult runnable)阻塞并多次执行操作,直到操作成功为止。此外,还会监控输出流的活动,如果在指定时间内没有观察到任何流活动,则会中止。如果将 idleOutputTimeout 设置为零,则不会进行任何数据流监控。
| 参数 | |
|---|---|
opTimeout |
long:单次操作尝试的等待时长上限(以毫秒为单位) |
idleOutputTimeout |
long:等待输出流输出数据的最大时间(以毫秒为单位) |
pollInterval |
long:操作尝试之间的初始等待时间 |
maxTime |
long:继续尝试执行操作的大致总时长 |
runnable |
IRunUtil.IRunnableResult:IRunUtil.IRunnableResult 要执行 |
| 返回 | |
|---|---|
boolean |
如果操作在 maxTime 过期之前成功完成,则返回 true |
runTimed
public abstract CommandStatus runTimed (long timeout, IRunUtil.IRunnableResult runnable, boolean logErrors)
阻塞并执行操作,如果操作花费的时间超过指定时间,则中止。
| 参数 | |
|---|---|
timeout |
long:等待时长上限(以毫秒为单位) |
runnable |
IRunUtil.IRunnableResult:IRunUtil.IRunnableResult 要执行 |
logErrors |
boolean:是否在发生异常时记录错误。 |
| 返回 | |
|---|---|
CommandStatus |
操作的 CommandStatus 结果。 |
runTimedCmd
public abstract CommandResult runTimedCmd (long timeout, OutputStream stdout, OutputStream stderr, String... command)
用于执行系统命令的辅助方法,如果执行时间超过指定时间,则会中止,并将输出重定向到文件(如果指定)。以这种方式提供 ERROR(/OutputStream) 时,它们会在函数结束时保持打开状态。
| 参数 | |
|---|---|
timeout |
long:超时等待的最长时间(以毫秒为单位)。0 表示无超时。 |
stdout |
OutputStream:将重定向 std 输出的 ERROR(/OutputStream)。可以为 null。 |
stderr |
OutputStream:错误输出将重定向到的 ERROR(/OutputStream)。可以为 null。 |
command |
String:指定的系统命令以及可选的 exec 参数 |
| 返回 | |
|---|---|
CommandResult |
包含命令运行结果的 CommandResult |
runTimedCmd
public abstract CommandResult runTimedCmd (long timeout, String... command)
用于执行系统命令的辅助方法,如果执行时间超过指定时间,则会中止。
| 参数 | |
|---|---|
timeout |
long:等待的最长时间(以毫秒为单位)。0 表示不超时。 |
command |
String:指定的系统命令以及可选的 exec 参数 |
| 返回 | |
|---|---|
CommandResult |
包含命令运行结果的 CommandResult |
runTimedCmdRetry
public abstract CommandResult runTimedCmdRetry (long timeout, long retryInterval, int attempts, String... command)
用于执行系统命令的辅助方法,如果执行时间超过指定时间,则会中止。
| 参数 | |
|---|---|
timeout |
long:每次尝试的等待时长上限(以毫秒为单位) |
retryInterval |
long:命令重试之间的等待时间 |
attempts |
int:尝试的最大次数 |
command |
String:指定的系统命令以及可选的 exec 参数 |
| 返回 | |
|---|---|
CommandResult |
包含命令运行结果的 CommandResult |
runTimedCmdRetryWithOutputMonitor
public abstract CommandResult runTimedCmdRetryWithOutputMonitor (long timeout, long idleOutputTimeout, long retryInterval, int attempts, String... command)
用于执行系统命令的辅助方法,如果执行时间超过指定时间,则会中止。此外,还会监控输出流的活动,如果在指定时间内没有观察到任何流活动,则会中止。如果将 idleOutputTimeout 设置为零,则不会进行任何数据流监控。
| 参数 | |
|---|---|
timeout |
long:每次尝试的等待时长上限(以毫秒为单位) |
idleOutputTimeout |
long:等待输出流输出数据的最大时间(以毫秒为单位) |
retryInterval |
long:命令重试之间的等待时间 |
attempts |
int:尝试的最大次数 |
command |
String:指定的系统命令以及可选的 exec 参数 |
| 返回 | |
|---|---|
CommandResult |
包含命令运行结果的 CommandResult |
runTimedCmdSilently
public abstract CommandResult runTimedCmdSilently (long timeout, String... command)
用于执行系统命令的辅助方法,如果执行时间超过指定时间,则会中止。与 runTimedCmd(long, String) 类似,但在发生异常时不会记录任何错误。
| 参数 | |
|---|---|
timeout |
long:等待时长上限(以毫秒为单位) |
command |
String:指定的系统命令以及可选的 exec 参数 |
| 返回 | |
|---|---|
CommandResult |
包含命令运行结果的 CommandResult |
runTimedCmdSilentlyRetry
public abstract CommandResult runTimedCmdSilentlyRetry (long timeout, long retryInterval, int attempts, String... command)
用于执行系统命令的辅助方法,如果执行时间超过指定时间,则会中止。与 runTimedCmdRetry(long, long, int, String[]) 类似,但在发生异常时不会记录任何错误。
| 参数 | |
|---|---|
timeout |
long:等待时长上限(以毫秒为单位) |
retryInterval |
long:命令重试之间的等待时间 |
attempts |
int:尝试的最大次数 |
command |
String:指定的系统命令以及可选的 exec 参数 |
| 返回 | |
|---|---|
CommandResult |
包含命令运行结果的 CommandResult |
runTimedCmdWithInput
public abstract CommandResult runTimedCmdWithInput (long timeout, String input, File stdoutFile, File stderrFile, String... command)
用于执行系统命令的辅助方法,如果执行时间超过指定时间,则会中止,并将输出重定向到文件(如果指定)。
| 参数 | |
|---|---|
timeout |
long:超时等待的最长时间(以毫秒为单位)。0 表示无超时。 |
input |
String:要传递给进程的 stdin 输入 |
stdoutFile |
File:将重定向 std 输出的 ERROR(/File)。可以为 null。 |
stderrFile |
File:错误输出将重定向到的 ERROR(/File)。可以为 null。 |
command |
String:指定的系统命令以及可选的 exec 参数 |
| 返回 | |
|---|---|
CommandResult |
包含命令运行结果的 CommandResult |
runTimedCmdWithInput
public abstract CommandResult runTimedCmdWithInput (long timeout, String input, String... command)
用于执行需要 stdin 输入的系统命令的辅助方法,如果执行时间超过指定时间,则会中止。
| 参数 | |
|---|---|
timeout |
long:等待时长上限(以毫秒为单位) |
input |
String:要传递给进程的 stdin 输入 |
command |
String:指定的系统命令以及可选的 exec 参数 |
| 返回 | |
|---|---|
CommandResult |
包含命令运行结果的 CommandResult |
runTimedCmdWithInput
public abstract CommandResult runTimedCmdWithInput (long timeout, String input,command)
用于执行需要 stdin 输入的系统命令的辅助方法,如果执行时间超过指定时间,则会中止。
| 参数 | |
|---|---|
timeout |
long:等待时长上限(以毫秒为单位) |
input |
String:要传递给进程的 stdin 输入 |
command |
:包含系统命令和可选的 exec 参数的 ERROR(/List) |
| 返回 | |
|---|---|
CommandResult |
包含命令运行结果的 CommandResult |
runTimedCmdWithInputRedirect
public abstract CommandResult runTimedCmdWithInputRedirect (long timeout, File inputRedirect, String... command)
用于执行需要从文件重定向 Stdin 的系统命令的辅助方法,如果执行时间超过指定时间,则会中止。
| 参数 | |
|---|---|
timeout |
long:等待时长上限(以毫秒为单位) |
inputRedirect |
File:要使用 ProcessBuilder.redirectInput() 重定向为标准输入的 ERROR(/File)。如果为 null,则不会重定向 stdin。 |
command |
String:指定的系统命令以及可选的 exec 参数 |
| 返回 | |
|---|---|
CommandResult |
包含命令运行结果的 CommandResult |
runTimedCmdWithOutputMonitor
public abstract CommandResult runTimedCmdWithOutputMonitor (long timeout, long idleOutputTimeout, OutputStream stdout, OutputStream stderr, String... command)
用于执行系统命令的辅助方法,如果执行时间超过指定时间,则会中止,并将输出重定向到文件(如果指定)。以这种方式提供 ERROR(/OutputStream) 时,它们会在函数结束时保持打开状态。
| 参数 | |
|---|---|
timeout |
long:超时等待的最长时间(以毫秒为单位)。0 表示不超时。 |
idleOutputTimeout |
long:等待输出流输出数据的最大时间(以毫秒为单位) |
stdout |
OutputStream:将重定向 std 输出的 ERROR(/OutputStream)。可以为 null。 |
stderr |
OutputStream:错误输出将重定向到的 ERROR(/OutputStream)。可以为 null。 |
command |
String:指定的系统命令以及可选的 exec 参数 |
| 返回 | |
|---|---|
CommandResult |
包含命令运行结果的 CommandResult |
runTimedCmdWithOutputMonitor
public abstract CommandResult runTimedCmdWithOutputMonitor (long timeout, long idleOutputTimeout, String... command)
用于执行系统命令的辅助方法,如果执行时间超过指定时间,则会中止。此外,还会监控输出流的活动,如果在指定时间内没有观察到任何流活动,则会中止。如果将 idleOutputTimeout 设置为零,则不会进行任何数据流监控。
| 参数 | |
|---|---|
timeout |
long:等待的最长时间(以毫秒为单位)。0 表示不超时。 |
idleOutputTimeout |
long:等待输出流输出数据的最大时间(以毫秒为单位) |
command |
String:指定的系统命令以及可选的 exec 参数 |
| 返回 | |
|---|---|
CommandResult |
包含命令运行结果的 CommandResult |
runTimedRetry
public abstract boolean runTimedRetry (long opTimeout,
long pollInterval,
int attempts,
IRunUtil.IRunnableResult runnable)阻塞并多次执行操作,直到操作成功为止。
| 参数 | |
|---|---|
opTimeout |
long:一次操作尝试的等待时长上限(以毫秒为单位) |
pollInterval |
long:命令重试之间的等待时间 |
attempts |
int:尝试的最大次数 |
runnable |
IRunUtil.IRunnableResult:IRunUtil.IRunnableResult 要执行 |
| 返回 | |
|---|---|
boolean |
如果操作在达到尝试次数之前成功完成,则返回 true。 |
runTimedRetryWithOutputMonitor
public abstract boolean runTimedRetryWithOutputMonitor (long opTimeout,
long idleOutputTimeout,
long pollInterval,
int attempts,
IRunUtil.IRunnableResult runnable)阻塞并多次执行操作,直到操作成功为止。此外,还会监控输出流的活动,如果在指定时间内没有观察到任何流活动,则会中止。如果将 idleOutputTimeout 设置为零,则不会进行任何数据流监控。
| 参数 | |
|---|---|
opTimeout |
long:一次操作尝试的等待时长上限(以毫秒为单位) |
idleOutputTimeout |
long:等待输出流输出数据的最大时间(以毫秒为单位) |
pollInterval |
long:命令重试之间的等待时间 |
attempts |
int:尝试的最大次数 |
runnable |
IRunUtil.IRunnableResult:IRunUtil.IRunnableResult 要执行 |
| 返回 | |
|---|---|
boolean |
如果操作在达到尝试次数上限之前成功完成,则返回 true。 |
runTimedWithOutputMonitor
public abstract CommandStatus runTimedWithOutputMonitor (long timeout, long idleOutputTimeout, IRunUtil.IRunnableResult runnable, boolean logErrors)
阻塞并执行操作,如果操作花费的时间超过指定时间,则中止。此外,还会监控输出流的活动,如果在指定时间内没有观察到任何流活动,则会中止。如果将 idleOutputTimeout 设置为零,则不会进行任何数据流监控。
| 参数 | |
|---|---|
timeout |
long:等待时长上限(以毫秒为单位) |
idleOutputTimeout |
long:等待输出流输出数据的最大等待时间(以毫秒为单位) |
runnable |
IRunUtil.IRunnableResult:IRunUtil.IRunnableResult 要执行 |
logErrors |
boolean:是否在发生异常时记录错误。 |
| 返回 | |
|---|---|
CommandStatus |
操作的 CommandStatus 结果。 |
setEnvVariable
public abstract void setEnvVariable (String key,
String value)设置要用于运行系统命令的环境变量。
| 参数 | |
|---|---|
key |
String:变量名称 |
value |
String:变量值 |
setEnvVariablePriority
public abstract void setEnvVariablePriority (IRunUtil.EnvPriority priority)
确定在创建进程时,取消设置环境变量的优先级是否高于设置环境变量。
默认情况下,取消设置的优先级更高:这意味着,如果尝试设置同名变量,则不会成功,因为系统会取消设置该变量。不能在默认的 IRunUtil 实例上使用。
| 参数 | |
|---|---|
priority |
IRunUtil.EnvPriority |
setInterruptibleInFuture
public abstract void setInterruptibleInFuture (Thread thread,
long timeMs)在等待一段时间后设为可中断。
ERROR(/CommandScheduler#shutdownHard()) 来强制执行最终终止。
| 参数 | |
|---|---|
thread |
Thread:将变为可中断的线程。 |
timeMs |
long:在设置可中断之前等待的时间。 |
setLinuxInterruptProcess
public abstract void setLinuxInterruptProcess (boolean interrupt)
允许在通过 #runTimed 方法运行的进程达到超时时使用 Linux“kill”中断。
不能在默认的 IRunUtil 实例上使用。
| 参数 | |
|---|---|
interrupt |
boolean |
setRedirectStderrToStdout
public abstract void setRedirectStderrToStdout (boolean redirect)
在运行系统命令时,将标准错误流设置为重定向到标准输出流。初始值为 false。
| 参数 | |
|---|---|
redirect |
boolean:用于指示是否重定向的新值 |
setWorkingDir
public abstract void setWorkingDir (File dir)
设置系统命令的工作目录。
| 参数 | |
|---|---|
dir |
File:工作目录 |
sleep
public abstract void sleep (long time)
用于指定时间休眠的辅助方法,会忽略任何异常。
| 参数 | |
|---|---|
time |
long:进入休眠状态所需的毫秒数。系统会忽略小于或等于 0 的值 |
unsetEnvVariable
public abstract void unsetEnvVariable (String key)
取消设置环境变量,以便系统命令在没有此环境变量的情况下运行。
| 参数 | |
|---|---|
key |
String:变量名称 |