Skip to content

Commit

Permalink
Use taskkill for win32 (#941)
Browse files Browse the repository at this point in the history
* Use taskkill for win32

* Use spawn + taskkill in windows

* Revert to using tree-kill

* Use taskkill

* Remove tree-kill

* Use spawnSync
  • Loading branch information
renkun-ken committed Jan 15, 2022
1 parent d968dec commit bf4098a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1726,7 +1726,6 @@
"node-fetch": "^2.6.1",
"popper.js": "^1.16.1",
"showdown": "^1.9.1",
"tree-kill": "^1.2.2",
"vscode-languageclient": "^7.0.0",
"vsls": "^1.0.4753",
"winreg": "^1.2.4",
Expand Down
6 changes: 4 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import * as vscode from 'vscode';
import * as cp from 'child_process';
import { rGuestService, isGuestSession } from './liveShare';
import { extensionContext } from './extension';
import * as kill from 'tree-kill';

export function config(): vscode.WorkspaceConfiguration {
return vscode.workspace.getConfiguration('r');
Expand Down Expand Up @@ -412,16 +411,19 @@ export function asDisposable<T>(toDispose: T, disposeFunction: (...args: unknown
export type DisposableProcess = cp.ChildProcessWithoutNullStreams & vscode.Disposable;
export function exec(command: string, args?: ReadonlyArray<string>, options?: cp.CommonOptions, onDisposed?: () => unknown): DisposableProcess {
const proc = cp.spawn(command, args, options);
console.log(`Process ${proc.pid} spawned`);
let running = true;
const exitHandler = () => {
running = false;
console.log(`Process ${proc.pid} exited`);
};
proc.on('exit', exitHandler);
proc.on('error', exitHandler);
const disposable = asDisposable(proc, () => {
if (running) {
console.log(`Process ${proc.pid} terminating`);
if (process.platform === 'win32') {
kill(proc.pid);
cp.spawnSync('taskkill', ['/pid', proc.pid.toString(), '/f', '/t']);
} else {
proc.kill('SIGKILL');
}
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2597,11 +2597,6 @@ to-regex-range@^5.0.1:
resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.3.9.tgz#717b8f220cc0bb7b44e40514c22b2e8bbc70d8b9"
integrity sha1-cXuPIgzAu3tE5AUUwisui7xw2Lk=

tree-kill@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc"
integrity sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==

ts-loader@^9.2.3:
version "9.2.3"
resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-9.2.3.tgz#dc3b6362a4d4382493cd4f138d345f419656de68"
Expand Down

0 comments on commit bf4098a

Please sign in to comment.