MCPcopy Index your code
hub / github.com/REditorSupport/vscode-R / spawn

Function spawn

src/util.ts:489–515  ·  view source on GitHub ↗
(command: string, args?: ReadonlyArray<string>, options?: cp.CommonOptions, onDisposed?: () => unknown)

Source from the content-addressed store, hash-verified

487
488export type DisposableProcess = cp.ChildProcessWithoutNullStreams & vscode.Disposable;
489export function spawn(command: string, args?: ReadonlyArray<string>, options?: cp.CommonOptions, onDisposed?: () => unknown): DisposableProcess {
490 const proc = cp.spawn(command, args, options);
491 console.log(proc.pid ? `Process ${proc.pid} spawned` : 'Process failed to spawn');
492 let running = true;
493 const exitHandler = () => {
494 running = false;
495 console.log(`Process ${proc.pid || ''} exited`);
496 };
497 proc.on('exit', exitHandler);
498 proc.on('error', exitHandler);
499 const disposable = asDisposable(proc, () => {
500 if (running) {
501 console.log(`Process ${proc.pid || ''} terminating`);
502 if (process.platform === 'win32') {
503 if (proc.pid !== undefined) {
504 cp.spawnSync('taskkill', ['/pid', proc.pid.toString(), '/f', '/t']);
505 }
506 } else {
507 proc.kill('SIGKILL');
508 }
509 }
510 if (onDisposed) {
511 onDisposed();
512 }
513 });
514 return disposable;
515}
516
517export async function spawnAsync(command: string, args?: ReadonlyArray<string>, options?: cp.CommonOptions, onDisposed?: () => unknown): Promise<cp.SpawnSyncReturns<string>> {
518 return new Promise((resolve) => {

Callers 4

spawnServerMethod · 0.90
knitDocumentFunction · 0.90
launchRHelpServerMethod · 0.90
spawnAsyncFunction · 0.85

Calls 1

asDisposableFunction · 0.85

Tested by

no test coverage detected