Skip to content

Commit 8af9293

Browse files
committed
fix(exit): windows may end up with zombie processes
1 parent 4146447 commit 8af9293

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

packages/workshop-app/bin/epicshop.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,17 +226,21 @@ async function start() {
226226
await doUpdateAndRestart()
227227
} else if (key === '\u0003') {
228228
// Ctrl+C
229-
await killChild(child)
230-
if (server) await new Promise((resolve) => server.close(resolve))
229+
await cleanupBeforeExit()
231230
process.exit(0)
232231
}
233232
})
234233
}
235234

236-
closeWithGrace(async () => {
235+
async function cleanupBeforeExit() {
236+
if (process.platform === 'win32' && child && child.pid) {
237+
spawn('taskkill', ['/pid', child.pid, '/f', '/t'])
238+
}
237239
await killChild(child)
238240
if (server) await new Promise((resolve) => server.close(resolve))
239-
})
241+
}
242+
243+
closeWithGrace(cleanupBeforeExit)
240244
}
241245

242246
async function killChild(child) {

0 commit comments

Comments
 (0)