1
>
/*---------------------------------------------------------------------------------------------
processes.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import * as cp from 'child_process';
7
>
import { Stats, promises } from 'fs';
8
>
import { getCaseInsensitive } from '../common/objects.js';
9
>
import * as path from '../common/path.js';
10
>
import * as Platform from '../common/platform.js';
11
>
import * as processCommon from '../common/process.js';
12
>
import { CommandOptions, ForkOptions, Source, SuccessData, TerminateResponse, TerminateResponseCode } from '../common/processes.js';
13
>
import * as Types from '../common/types.js';
14
>
import * as pfs from './pfs.js';
15
>
import { FileAccess } from '../common/network.js';
16
>
import Stream from 'stream';
17
>
export { Source, TerminateResponseCode, type CommandOptions, type ForkOptions, type SuccessData, type TerminateResponse };
18
>
19
>
export type ValueCallback<T> = (value: T | Promise<T>) => void;
20
>
export type ErrorCallback = (error?: any) => void;
21
>
export type ProgressCallback<T> = (progress: T) => void;
22
>
23
>
24
>
export function getWindowsShell(env = processCommon.env): string {
25
return env['comspec'] || 'cmd.exe';
26
}
28
>
export interface IQueuedSender {
29
>
send: (msg: any) => void;
30
>
}
31
>
32
>
// Wrapper around process.send() that will queue any messages if the internal node.js
33
>
// queue is filled with messages and only continue sending messages when the internal
34
>
// queue is free again to consume messages.
35
>
// On Windows we always wait for the send() method to return before sending the next message
36
>
// to workaround https://github.com/nodejs/node/issues/7657 (IPC can freeze process)
37
>
export function createQueuedSender(childProcess: cp.ChildProcess): IQueuedSender {
38
let msgQueue: string[] = [];
39
let useQueue = false;