ProcessGroup p = sshell.createProcessGroup(job);
if (p == null) {
throw new ShellException("[ShellImpl][execute] Failed to create ProcessGroup.");
}
InBuffer ib = ((Process) job.getFirst()).getInputBuffer();
OutBuffer ob = ((Process) job.getLast()).getOutputBuffer();
p.setRedirected(((Process) job.getLast()).isRedirected());
//log.debug("PRocessGroup ib: " + ib);
//log.debug("PRocessGroup ob: " + ob);
p.setInputBuffer(ib);
p.setOutputBuffer(ob);
p.setCommandLine(cmdline);
if (active == null) {
active = p;
}
// if(interactive) {
// outreader.replacePrimaryBuffer(ob);
// }
procmap.put(p.getID(), p);
p.setUserInitiated(ui);
hi.setProcessID(p.getID());
// We don't use it anywhere - WRONG - we use it when NoProcessForID Exceptions occur
LinkedList chs = hi.getChildren();
LinkedList ls = p.getProcessList();
it = ls.iterator();
while(it.hasNext()) {
Process cp = (Process) it.next();
chs.add(cp);
}
if (!prepareOnly) {
p.start(); // We have a problem with concurrent modification on job
} else {
preparedProcess.set(p);
}
ProcessInfo pinfo = new ProcessInfo();
pinfo.procid = p.getID();
pinfo.inbuf_maxsize = ib.getMaxSize();
pinfo.outbuf_maxsize = ob.getMaxSize();
return pinfo;
} else {
Process p = (Process) job.getFirst();
// System.out.println("Putting the process in the procmap: " + p.getID() + " : " + p);
InBuffer ib = p.getInputBuffer();
OutBuffer ob = p.getOutputBuffer();
//log.debug("PRocess ib: " + ib);
//log.debug("PRocess ob: " + ob);
if (active == null) {
active = p;
}
// if(interactive) {
// outreader.replacePrimaryBuffer(ob);
// }
// System.out.println("ACTIVE SET: " + active);
procmap.put(p.getID(), p);
//log.debug("***\n***[execute] Created process " + p.getID() + "\n***");
log.debug("Created process " + p.getID());
p.setUserInitiated(ui);
hi.setProcessID(p.getID());
hi.getChildren().add(p);
if (!prepareOnly) {
p.start();
} else {
preparedProcess.set(p);
}
// System.out.println("Started the process.");
ProcessInfo pinfo = new ProcessInfo();
pinfo.procid = p.getID();
pinfo.inbuf_maxsize = ib.getMaxSize();
pinfo.outbuf_maxsize = ob.getMaxSize();
return pinfo;
}
} catch (SessionTimeoutException ex) {
throw new SessionTimeoutException("Exception executing: " + cmdline + " - " + ex.getMessage());
} catch (ParseException ex) {