final ScriptProcess p = datastore.newProcess(TEST_USER, "kill.js", false, "", "owner", TransportType.Dummy);
p.save();
ScriptAction r = p.call();
assertTrue("Forked correctly", r instanceof Fork);
final ThreadLocal<Boolean> executedParentPostFork = new ThreadLocal<Boolean>();
final ThreadLocal<Boolean> executedParentPostKill = new ThreadLocal<Boolean>();
final ThreadLocal<Boolean> executedChild = new ThreadLocal<Boolean>();
ScriptusFacade testFacade = new ScriptusFacade(datastore, c, m, conf) {
private UUID childPid;
@Override
public void execute(UUID pid) {
if( ! pid.equals(p.getPid())) {
//executing child
executedChild.set(Boolean.TRUE);
childPid = pid;
super.execute(pid);
return;
}
if(pid.equals(p.getPid())) {
//executing parent
if(Boolean.TRUE.equals(executedParentPostFork.get())) {
//post-kill
executedParentPostKill.set(Boolean.TRUE);
} else {
//post-fork, pre-kill, pid
executedParentPostFork.set(Boolean.TRUE);
ScriptProcess p2 = datastore.getProcess(pid);
ScriptAction r2 = p2.call();
p2.save();
assertTrue("Killed correctly", r2 instanceof Kill);
r2.visit(this, p2);
boolean caughtNotFoundExcepton = false;
try {
datastore.getProcess(childPid);