diff options
-rw-r--r-- | src/bun.js/api/bun/subprocess.zig | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/bun.js/api/bun/subprocess.zig b/src/bun.js/api/bun/subprocess.zig index 5681f5bae..ce64f3787 100644 --- a/src/bun.js/api/bun/subprocess.zig +++ b/src/bun.js/api/bun/subprocess.zig @@ -61,8 +61,7 @@ pub const Subprocess = struct { pub fn unref(this: *Subprocess) void { this.this_jsvalue.clear(); - this.reffer.unref(this.globalThis.bunVM()); - this.poll_ref.unref(this.globalThis.bunVM()); + this.unrefWithoutGC(this.globalThis.bunVM()); } pub fn constructor( @@ -691,7 +690,7 @@ pub const Subprocess = struct { }; } } - sink.watch(fd); + // sink.watch(fd); return Writable{ .pipe = sink }; }, .array_buffer, .blob => { @@ -1208,12 +1207,19 @@ pub const Subprocess = struct { } if (!sync) { + var vm = this.globalThis.bunVM(); + this.unrefWithoutGC(vm); this.waitpid_task = JSC.AnyTask.New(Subprocess, onExit).init(this); this.has_waitpid_task = true; - this.globalThis.bunVM().eventLoop().enqueueTask(JSC.Task.init(&this.waitpid_task)); + vm.eventLoop().enqueueTask(JSC.Task.init(&this.waitpid_task)); } } + pub fn unrefWithoutGC(this: *Subprocess, vm: *JSC.VirtualMachine) void { + this.poll_ref.unref(vm); + this.reffer.unref(vm); + } + fn onExit(this: *Subprocess) void { this.closePorts(); |