LOG.debug("waiting for "+childPid.toString().substring(30));
final UUID parentPid = process.getPid();
if( ! scriptus.getChildren(parentPid).contains(childPid)) {
throw new ScriptusRuntimeException("not a child: "+childPid);
}
scriptus.updateProcessState(parentPid, this);
try {
scriptus.runWithLock(childPid, new Runnable() {
@Override
public void run() {
ScriptProcess child = scriptus.getProcess(childPid); //overwrites state with child
//already terminated
if(child.getState() instanceof Termination) {
//FIXME we should delete child & remove from list of children
scriptus.updateProcessState(parentPid, ((Termination)child.getState()).getResult());
scriptus.execute(parentPid);
return;
}
LOG.debug("registering waiter for " + childPid.toString().substring(30) + ", waiterpid="
+ parentPid.toString().substring(30));
child.setWaiterPid(parentPid);
child.save();
}
});
} catch (Exception e) {
throw new ScriptusRuntimeException(e);
}
}