Skip to content

Commit

Permalink
jsc/wasm32/wasm32.jsc: don't return from wait4() too early
Browse files Browse the repository at this point in the history
  • Loading branch information
pipcet committed Feb 2, 2021
1 parent 140e2d5 commit 3133345
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions jsc/wasm32/wasm32.jsc
Original file line number Diff line number Diff line change
Expand Up @@ -1630,6 +1630,7 @@ function Wasm32Kernel()
this.threads_by_port = new WeakMap();
this.ppids = { 1: 1 };
this.wait4 = {};
this.exited = {};
this.seq = 0;
this.requesters = {};
this.responders = {};
Expand Down Expand Up @@ -1704,6 +1705,7 @@ Wasm32Kernel.prototype.message = function (port, data)
var ppid = this.ppids[pid];
var pport = this.ports_by_pid[ppid];

this.exited[pid] = true;
if (this.ports_by_pid[ppid]) {
this.ports_by_pid[ppid].postMessage(["response", this.wait4[ppid], [pid, exitcode]]);
}
Expand All @@ -1712,6 +1714,7 @@ Wasm32Kernel.prototype.message = function (port, data)
} else if (data[0] === "wait4") {
var pid = this.pids_by_port.get(port);
this.wait4[pid] = seq;
if (this.exited[pid])
this.ports_by_pid[pid].postMessage(["response", this.wait4[pid], [data[1], 0]]);
} else {
console.log(data);
Expand Down

0 comments on commit 3133345

Please sign in to comment.