Skip to content

Commit 770fc52

Browse files
committed
refactor: use graceful termination in process name-based cleanup
- Changed from immediate force kill to graceful termination first - Windows: try taskkill without /F first, escalate to /F on failure - Unix: use existing killProcessGracefully helper (SIGTERM then SIGKILL) - Matches the graceful termination pattern from port-based cleanup - Preserves throwOnStdErr: false behavior throughout - Gives processes a chance to clean up before force termination - More consistent behavior across all cleanup code paths
1 parent 096d858 commit 770fc52

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/kernels/deepnote/deepnoteServerStarter.node.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,11 +1062,23 @@ export class DeepnoteServerStarter implements IDeepnoteServerStarter, IExtension
10621062
for (const pid of pidsToKill) {
10631063
try {
10641064
if (process.platform === 'win32') {
1065-
await processService.exec('taskkill', ['/F', '/T', '/PID', pid.toString()], {
1066-
throwOnStdErr: false
1067-
});
1065+
// Windows: Try graceful kill first (without /F), then force kill if needed
1066+
logger.debug(`Attempting graceful termination of process ${pid}...`);
1067+
try {
1068+
await processService.exec('taskkill', ['/T', '/PID', pid.toString()], {
1069+
throwOnStdErr: false
1070+
});
1071+
logger.debug(`Gracefully killed process ${pid}`);
1072+
} catch (gracefulError) {
1073+
// If graceful kill failed, use /F (force)
1074+
logger.debug(`Graceful kill failed for ${pid}, using /F flag...`);
1075+
await processService.exec('taskkill', ['/F', '/T', '/PID', pid.toString()], {
1076+
throwOnStdErr: false
1077+
});
1078+
}
10681079
} else {
1069-
await processService.exec('kill', ['-9', pid.toString()], { throwOnStdErr: false });
1080+
// Unix: Use helper that tries SIGTERM then SIGKILL
1081+
await this.killProcessGracefully(pid, processService);
10701082
}
10711083
logger.info(`Killed orphaned process ${pid}`);
10721084

0 commit comments

Comments
 (0)