/**
* This method is resonsible for cleaning all files created by running a process.
*/
private void processCMDCLEAN_REQUEST(DataInputStream in, DataOutputStream out) {
TestObject test=new TestObject();
try {
ConsoleServer.debugMsg("Processing CMDCLEAN_REQUEST",1);
// read the serialized TestObject which we want the exit code of
test.readObject(in);
// now send a signal indicating we are processing the request
sendSignal(out,ProtocolConstants.RESPONSE_PROCESSING);
// find the exit code, blocking if neccesary
ExecProcess proc;
boolean exists = false;
for (int i = 0; i < processPool.size(); i++) {
try {
proc = (ExecProcess)processPool.get(i);
}
catch (java.lang.NoSuchMethodError ex) {
// does not exist in jdk1.1.x
proc = (ExecProcess)processPool.elementAt(i);
}
// check for any instance of test running with the same name
if (proc.getTestObject().getTestID().equals(test.getTestID())) {
try {
ConsoleServer.debugMsg("Deleting :"+proc.getTestObject().getEnvFileName(),5);
Utils.delete(proc.getTestObject().getEnvFileName());
}
catch (IOException e) {
ConsoleServer.debugMsg("No environment file was found :"+e,1);
}
try {
ConsoleServer.debugMsg("Deleting :"+proc.getTestObject().getStdOutFileName(),5);
Utils.delete(proc.getTestObject().getStdOutFileName());
}
catch (IOException e) {
ConsoleServer.debugMsg("No stdout file was found :"+e,1);
}
try {
ConsoleServer.debugMsg("Deleting :"+proc.getTestObject().getStdErrFileName(),5);
Utils.delete(proc.getTestObject().getStdErrFileName());
}
catch (IOException e) {
ConsoleServer.debugMsg("No stderr file was found :"+e,1);
}
exists = true;
// flush and close it's output streams by doing a STOP command
proc.interrupt();
try {
processPool.remove(i);
}
catch (java.lang.NoSuchMethodError ex) {
// does not exist in jdk1.1.x
processPool.removeElementAt(i);
}
break;
}
}
if (!exists) {
// the process was never started, so assume it failed
ConsoleServer.debugMsg("Process was not running :"+test.getTestID(),1);
out.writeInt(ProtocolConstants.FAILED);
}
else {
// now send a signal indicating we have finished
sendSignal(out,ProtocolConstants.RESPONSE_FINISHED_OK);