Skip to content

Commit

Permalink
SDA-4386 (Properly terminate c9 shell on exiting the application) (#2012
Browse files Browse the repository at this point in the history
)

* SDA-4386 - Properly terminate c9 shell on exiting the application

* SDA-4386 - Wait for the C9 process to terminate
  • Loading branch information
KiranNiranjan authored Nov 16, 2023
1 parent ee7ce7d commit 4611f66
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/app/c9-shell-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class C9ShellHandler {
/**
* Terminates the c9shell process if it was started by this handler.
*/
public terminateShell() {
public terminateShell = async () => {
if (this._isTerminating) {
logger.info('c9-shell-handler: _isTerminating, skip terminate');
return;
Expand All @@ -91,7 +91,12 @@ class C9ShellHandler {
logger.info('c9-shell-handler: terminate');
this._isTerminating = true;
this._c9shell.kill();
}
return new Promise<number>((resolve) => {
this._c9shell?.on('exit', (code) => {
resolve(code || 0);
});
});
};

/**
* Update the current shell status and notify the callback if set.
Expand Down Expand Up @@ -246,9 +251,9 @@ export const loadC9Shell = async (sender: WebContents) => {
/**
* Terminates the C9 shell process asynchronously, if it is running.
*/
export const terminateC9Shell = () => {
export const terminateC9Shell = async () => {
if (!c9ShellHandler) {
return;
}
c9ShellHandler.terminateShell();
await c9ShellHandler.terminateShell();
};
2 changes: 2 additions & 0 deletions src/app/window-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { AppMenu } from './app-menu';
import { analytics } from './bi/analytics-handler';
import { SDAEndReasonTypes, SDAUserSessionActionTypes } from './bi/interface';
import { closeC9Pipe } from './c9-pipe-handler';
import { terminateC9Shell } from './c9-shell-handler';
import { handleChildWindow } from './child-window-handler';
import {
CloudConfigDataTypes,
Expand Down Expand Up @@ -2344,6 +2345,7 @@ export class WindowHandler {
if (shouldRelaunch) {
app.relaunch();
}
await terminateC9Shell();
app.exit();
};

Expand Down

0 comments on commit 4611f66

Please sign in to comment.