/** Chroot to the this path (must not be empty) */
private String chroot = null;
+ // Current
+ /** Current watchdog, null if process is completed */
+ ExecuteWatchdog currentWatchdog = null;
+
/** Empty constructor */
public SystemCall() {
executorToUse = executor;
else
executorToUse = new DefaultExecutor();
- executorToUse.setWatchdog(new ExecuteWatchdog(watchdogTimeout));
+ executorToUse.setWatchdog(createWatchdog());
if (redirectStreams) {
// Redirect standard streams
testResult.addResultPart(new SimpleResultPart(
TestStatus.PASSED, msg));
}
+ releaseWatchdog();
}
public void onProcessFailed(ExecuteException e) {
else
log.error(msg, e);
}
+ releaseWatchdog();
}
};
}
return this;
}
+ // CONTROL
+ public synchronized Boolean isRunning() {
+ return currentWatchdog != null;
+ }
+
+ private synchronized ExecuteWatchdog createWatchdog() {
+ if (currentWatchdog != null)
+ throw new SlcException("A process is already being monitored");
+ currentWatchdog = new ExecuteWatchdog(watchdogTimeout);
+ return currentWatchdog;
+ }
+
+ private synchronized void releaseWatchdog() {
+ currentWatchdog = null;
+ }
+
+ public synchronized void kill() {
+ if (currentWatchdog != null)
+ currentWatchdog.destroyProcess();
+ }
+
/** */
public void setCmd(String command) {
this.cmd = command;