Skip to content

Commit

Permalink
fix pid typings
Browse files Browse the repository at this point in the history
Signed-off-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
  • Loading branch information
vince-fugnitto committed Feb 10, 2023
1 parent 1e0107b commit 4e6fe37
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion packages/core/src/electron-main/electron-main-application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,9 @@ export class ElectronMainApplication {
try {
// If we forked the process for the clusters, we need to manually terminate it.
// See: https://github.com/eclipse-theia/theia/issues/835
process.kill(backendProcess.pid);
if (backendProcess.pid) {
process.kill(backendProcess.pid);
}
} catch (error) {
// See https://man7.org/linux/man-pages/man2/kill.2.html#ERRORS
if (error.code === 'ESRCH') {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-dev/src/node/hosted-instance-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export abstract class AbstractHostedInstanceManager implements HostedInstanceMan

terminate(): void {
if (this.isPluginRunning) {
this.hostedPluginProcess.killProcessTree(this.hostedInstanceProcess.pid);
this.hostedPluginProcess.killProcessTree(this.hostedInstanceProcess.pid!);
this.hostedPluginSupport.sendLog({ data: 'Hosted instance has been terminated', type: LogType.Info });
this.isPluginRunning = false;
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-dev/src/node/hosted-plugins-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class HostedPluginsManagerImpl implements HostedPluginsManager {
throw new Error('Watcher is not running in ' + pluginPath);
}

this.killProcessTree(watchProcess.pid);
this.killProcessTree(watchProcess.pid!);
return Promise.resolve();
}

Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-ext/src/hosted/node/hosted-plugin-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class HostedPluginProcess implements ServerPluginRunner {
await waitForTerminated.promise;
}

this.killProcessTree(cp.pid);
this.killProcessTree(cp.pid!);
}

killProcessTree(parentPid: number): void {
Expand Down Expand Up @@ -206,7 +206,7 @@ export class HostedPluginProcess implements ServerPluginRunner {
childProcess.stderr!.on('data', data => this.logger.error(`[${options.serverName}: ${childProcess.pid}] ${data.toString().trim()}`));

this.logger.debug(`[${options.serverName}: ${childProcess.pid}] IPC started`);
childProcess.once('exit', (code: number, signal: string) => this.onChildProcessExit(options.serverName, childProcess.pid, code, signal));
childProcess.once('exit', (code: number, signal: string) => this.onChildProcessExit(options.serverName, childProcess.pid!, code, signal));
childProcess.on('error', err => this.onChildProcessError(err));
return childProcess;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/process/src/node/raw-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class RawProcess extends Process {
if (!this.process) {
throw new Error('process did not start correctly');
}
return this.process.pid;
return this.process.pid!;
}

kill(signal?: string): void {
Expand Down

0 comments on commit 4e6fe37

Please sign in to comment.