Skip to content

Commit

Permalink
Call unref on child process when destroy invoked (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
05nelsonm authored Apr 26, 2024
1 parent 520f839 commit 26acb3e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ abstract class ProcessBaseTest {
.args("1")
.args("--RunAsDaemon")
.args("0")
.args("--__OwningControllerProcess")
.args(Process.Current.pid().toString())
.destroySignal(Signal.SIGTERM)
.envHome()
.stdin(Stdio.Null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ internal external class child_process_ChildProcess: events_EventEmitter {
internal val stdin: stream_Writable?
internal val stdout: stream_Readable?
internal val stderr: stream_Readable?

internal fun unref()
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ internal class NodeJsProcess internal constructor(
) {

override fun destroy(): Process {
val wasDestroyed = !isDestroyed
isDestroyed = true

if (!jsProcess.killed && isAlive) {
// TODO: check result. check error
jsProcess.kill(destroySignal.name)
}

if (wasDestroyed) jsProcess.unref()

return this
}

Expand Down

0 comments on commit 26acb3e

Please sign in to comment.