Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

exit(PID,kill) is special, it circumvents trap_exit, and generates a …

…regular exit signal with reason killed.
  • Loading branch information...
commit 292d514563c12c938720855ad081774bf1654fb3 1 parent 60dcb1c
@krestenkrab krestenkrab authored
View
5 src/main/java/erjang/EInternalPort.java
@@ -22,8 +22,6 @@
import java.nio.ByteBuffer;
import kilim.Pausable;
-
-import erjang.ETask.State;
import erjang.driver.EDriverTask;
/**
@@ -39,8 +37,9 @@ public String toString() {
return "<port:" + task.id + ">";
}
+ // TODO: private final WeakReference<EDriverTask> task;
private final EDriverTask task;
-
+
public EInternalPort(EDriverTask task) {
super(ERT.getLocalNode());
this.task = task;
View
24 src/main/java/erjang/EProc.java
@@ -49,7 +49,7 @@
public static final EAtom am_high = EAtom.intern("high");
private static final EObject am_kill = EAtom.intern("kill");
- private static final EObject am_init = EAtom.intern("init");
+ private static final EObject am_killed = EAtom.intern("killed");
public EFun tail;
public EObject arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8;
@@ -140,23 +140,27 @@ protected void link_failure(EHandle h) throws Pausable {
protected void process_incoming_exit(EHandle from, EObject reason) throws Pausable
{
- if (trap_exit == ERT.TRUE) {
+ if (from == self_handle()) {
+ return;
+
+ } else if (reason == am_kill) {
+ this.exit_reason = am_killed;
+ this.pstate = State.EXIT_SIG;
+ this.resume();
+
+ } else if (trap_exit == ERT.TRUE) {
// we're trapping exits, so we in stead send an {'EXIT', from,
// reason} to self
ETuple msg = ETuple.make(ERT.EXIT, from, reason);
- System.err.println("kill message to self: "+msg);
- if (reason == am_kill && ERT.whereis(am_init)==from) {
- this.exit_reason = reason;
- this.pstate = State.EXIT_SIG;
- return;
- }
+ // System.err.println("kill message to self: "+msg);
mbox_send(msg);
- resume(); // why did we not wake to life?
+
} else if (reason != am_normal) {
- System.err.println("kill signal: " +reason + " from "+from);
+ // System.err.println("kill signal: " +reason + " from "+from);
// try to kill this thread
this.exit_reason = reason;
this.pstate = State.EXIT_SIG;
+ this.resume();
}
}
View
3  src/main/java/erjang/driver/EDriverTask.java
@@ -490,6 +490,9 @@ public void execute() throws Pausable {
@Override
protected void process_incoming_exit(EHandle from, EObject reason)
throws Pausable {
+
+ // TODO: do special things for reason=kill ?
+
System.err.println("sending exit msg to self "+this);
mbox.put(ETuple.make(ERT.EXIT, from, reason));
}
Please sign in to comment.
Something went wrong with that request. Please try again.