Skip to content

Commit d750ebd

Browse files
committed
refactor: only pass watchdog pid
1 parent d0273cc commit d750ebd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/index.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
Serializable,
55
spawn as nodeSpawn,
66
SpawnOptions,
7+
ChildProcess,
78
} from 'child_process'
89
import crossSpawn from 'cross-spawn'
910
import { onExit } from 'signal-exit'
@@ -38,8 +39,8 @@ export type Cleanup = (
3839
code: number | null,
3940
signal: null | NodeJS.Signals,
4041
processInfo: {
41-
watchdog: ChildProcess
42-
}
42+
watchdogPid: ChildProcess['pid']
43+
},
4344
) =>
4445
| void
4546
| undefined
@@ -162,7 +163,7 @@ export function foregroundChild(
162163
const removeOnExit = onExit(childHangup)
163164

164165
proxySignals(child)
165-
watchdog(child)
166+
const dog = watchdog(child)
166167

167168
let done = false
168169
child.on('close', async (code, signal) => {
@@ -171,7 +172,7 @@ export function foregroundChild(
171172
/* c8 ignore stop */
172173
done = true
173174
const result = cleanup(code, signal, {
174-
watchdog: dog,
175+
watchdogPid: dog.pid,
175176
})
176177
const res = isPromise(result) ? await result : result
177178
removeOnExit()

0 commit comments

Comments
 (0)