child_process: support `Symbol.dispose` · nodejs/node@4e08160 · GitHub
Skip to content

Commit 4e08160

Browse files
MoLowjuanarbol
authored andcommitted
child_process: support Symbol.dispose
PR-URL: #48551 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent e2d0195 commit 4e08160

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

doc/api/child_process.md

Lines changed: 10 additions & 0 deletions

lib/internal/child_process.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const {
1212
ReflectApply,
1313
StringPrototypeSlice,
1414
Symbol,
15+
SymbolDispose,
1516
Uint8Array,
1617
} = primordials;
1718

@@ -516,6 +517,12 @@ ChildProcess.prototype.kill = function(sig) {
516517
return false;
517518
};
518519

520+
ChildProcess.prototype[SymbolDispose] = function() {
521+
if (!this.killed) {
522+
this.kill();
523+
}
524+
};
525+
519526

520527
ChildProcess.prototype.ref = function() {
521528
if (this._handle) this._handle.ref();
Lines changed: 25 additions & 0 deletions

0 commit comments

Comments
 (0)