Skip to content

Commit b7a3056

Browse files
committed
Don't kill running program if we didn't start it
Previously, the debugger would kill any program started with brickrun even if it wasn't started from this extension. This means that the debugger would say that console-runner was busy and not run the users program, but also the currently running program would be killed, so it would look like the remote device was not actually running a program. This fixes the problem by keeping track of the debug session ID and only sends the kill signal if the debug session actually started a program and it has not ended yet.
1 parent 8ce744f commit b7a3056

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/extension.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ async function pickDevice(): Promise<void> {
8484
});
8585
}
8686

87+
const activeDebugSessions = new Set<string>();
88+
8789
async function handleCustomDebugEvent(event: vscode.DebugSessionCustomEvent): Promise<void> {
8890
let device: Device | undefined;
8991
switch (event.event) {
@@ -133,6 +135,7 @@ async function handleCustomDebugEvent(event: vscode.DebugSessionCustomEvent): Pr
133135
else {
134136
output.appendLine(`Exited with signal ${signal}.`);
135137
}
138+
activeDebugSessions.delete(event.session.id);
136139
});
137140
channel.on('data', (chunk) => {
138141
output.append(chunk.toString());
@@ -142,6 +145,7 @@ async function handleCustomDebugEvent(event: vscode.DebugSessionCustomEvent): Pr
142145
});
143146
output.appendLine('Started.');
144147
output.appendLine('----------');
148+
activeDebugSessions.add(event.session.id);
145149
}
146150
catch (err) {
147151
await event.session.customRequest('ev3devBrowser.debugger.terminate');
@@ -150,7 +154,7 @@ async function handleCustomDebugEvent(event: vscode.DebugSessionCustomEvent): Pr
150154
break;
151155
case 'ev3devBrowser.debugger.stop':
152156
device = ev3devBrowserProvider.getDeviceSync();
153-
if (device && device.isConnected) {
157+
if (activeDebugSessions.has(event.session.id) && device && device.isConnected) {
154158
device.exec('conrun-kill --signal=SIGKILL');
155159
}
156160
break;

0 commit comments

Comments
 (0)