summaryrefslogtreecommitdiff
path: root/runtime/js/40_spawn.js
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/js/40_spawn.js')
-rw-r--r--runtime/js/40_spawn.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/runtime/js/40_spawn.js b/runtime/js/40_spawn.js
index a00b8cfda..87db84f4b 100644
--- a/runtime/js/40_spawn.js
+++ b/runtime/js/40_spawn.js
@@ -75,6 +75,7 @@
class Child {
#rid;
#waitPromiseId;
+ #unrefed = false;
#pid;
get pid() {
@@ -132,6 +133,7 @@
this.#stdoutRid = stdoutRid;
this.#stdout = readableStreamForRid(stdoutRid, (promise) => {
this.#stdoutPromiseId = promise[promiseIdSymbol];
+ if (this.#unrefed) core.unrefOp(this.#stdoutPromiseId);
});
}
@@ -139,6 +141,7 @@
this.#stderrRid = stderrRid;
this.#stderr = readableStreamForRid(stderrRid, (promise) => {
this.#stderrPromiseId = promise[promiseIdSymbol];
+ if (this.#unrefed) core.unrefOp(this.#stderrPromiseId);
});
}
@@ -204,12 +207,14 @@
}
ref() {
+ this.#unrefed = false;
core.refOp(this.#waitPromiseId);
if (this.#stdoutPromiseId) core.refOp(this.#stdoutPromiseId);
if (this.#stderrPromiseId) core.refOp(this.#stderrPromiseId);
}
unref() {
+ this.#unrefed = true;
core.unrefOp(this.#waitPromiseId);
if (this.#stdoutPromiseId) core.unrefOp(this.#stdoutPromiseId);
if (this.#stderrPromiseId) core.unrefOp(this.#stderrPromiseId);