Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
0a03c66c
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0a03c66c
编写于
3月 12, 2016
作者:
A
Andre Weinand
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "stdfork respect stderr"
This reverts commit
dd7709ec
.
上级
0ceed647
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
22 addition
and
69 deletion
+22
-69
extensions/typescript/src/utils/electron.ts
extensions/typescript/src/utils/electron.ts
+8
-19
extensions/typescript/src/utils/electronForkStart.ts
extensions/typescript/src/utils/electronForkStart.ts
+3
-16
src/vs/base/node/stdFork.ts
src/vs/base/node/stdFork.ts
+8
-18
src/vs/base/node/stdForkStart.js
src/vs/base/node/stdForkStart.js
+3
-16
未找到文件。
extensions/typescript/src/utils/electron.ts
浏览文件 @
0a03c66c
...
@@ -37,7 +37,7 @@ function generatePipeName(): string {
...
@@ -37,7 +37,7 @@ function generatePipeName(): string {
return
path
.
join
(
os
.
tmpdir
(),
randomName
+
'
.sock
'
);
return
path
.
join
(
os
.
tmpdir
(),
randomName
+
'
.sock
'
);
}
}
function
generatePatchedEnv
(
env
:
any
,
stdInPipeName
:
string
,
stdOutPipeName
:
string
,
stdErrPipeName
:
string
):
any
{
function
generatePatchedEnv
(
env
:
any
,
stdInPipeName
:
string
,
stdOutPipeName
:
string
):
any
{
// Set the two unique pipe names and the electron flag as process env
// Set the two unique pipe names and the electron flag as process env
var
newEnv
:
any
=
{};
var
newEnv
:
any
=
{};
...
@@ -47,7 +47,6 @@ function generatePatchedEnv(env:any, stdInPipeName:string, stdOutPipeName:string
...
@@ -47,7 +47,6 @@ function generatePatchedEnv(env:any, stdInPipeName:string, stdOutPipeName:string
newEnv
[
'
STDIN_PIPE_NAME
'
]
=
stdInPipeName
;
newEnv
[
'
STDIN_PIPE_NAME
'
]
=
stdInPipeName
;
newEnv
[
'
STDOUT_PIPE_NAME
'
]
=
stdOutPipeName
;
newEnv
[
'
STDOUT_PIPE_NAME
'
]
=
stdOutPipeName
;
newEnv
[
'
STDERR_PIPE_NAME
'
]
=
stdErrPipeName
;
newEnv
[
'
ATOM_SHELL_INTERNAL_RUN_AS_NODE
'
]
=
'
1
'
;
newEnv
[
'
ATOM_SHELL_INTERNAL_RUN_AS_NODE
'
]
=
'
1
'
;
return
newEnv
;
return
newEnv
;
...
@@ -71,38 +70,29 @@ export function fork(modulePath: string, args: string[], options: IForkOptions,
...
@@ -71,38 +70,29 @@ export function fork(modulePath: string, args: string[], options: IForkOptions,
callback
(
err
,
null
);
callback
(
err
,
null
);
};
};
// Generate t
hree
unique pipe names
// Generate t
wo
unique pipe names
var
stdInPipeName
=
generatePipeName
();
var
stdInPipeName
=
generatePipeName
();
var
stdOutPipeName
=
generatePipeName
();
var
stdOutPipeName
=
generatePipeName
();
let
stdErrPipeName
=
generatePipeName
();
var
newEnv
=
generatePatchedEnv
(
options
.
env
||
process
.
env
,
stdInPipeName
,
stdOutPipeName
);
var
newEnv
=
generatePatchedEnv
(
options
.
env
||
process
.
env
,
stdInPipeName
,
stdOutPipeName
,
stdErrPipeName
);
var
childProcess
:
cp
.
ChildProcess
;
var
childProcess
:
cp
.
ChildProcess
;
// Begin listening to stderr pipe
let
stdErrServer
=
net
.
createServer
((
stdErrStream
)
=>
{
// From now on the childProcess.stderr is available for reading
childProcess
.
stderr
=
stdErrStream
;
});
stdErrServer
.
listen
(
stdErrPipeName
);
// Begin listening to stdout pipe
// Begin listening to stdout pipe
let
stdOutServer
=
net
.
createServer
((
stdOutS
tream
)
=>
{
var
server
=
net
.
createServer
((
s
tream
)
=>
{
// The child process will write exactly one chunk with content `ready` when it has installed a listener to the stdin pipe
// The child process will write exactly one chunk with content `ready` when it has installed a listener to the stdin pipe
st
dOutSt
ream
.
once
(
'
data
'
,
(
chunk
:
Buffer
)
=>
{
stream
.
once
(
'
data
'
,
(
chunk
:
Buffer
)
=>
{
// The child process is sending me the `ready` chunk, time to connect to the stdin pipe
// The child process is sending me the `ready` chunk, time to connect to the stdin pipe
childProcess
.
stdin
=
<
any
>
net
.
connect
(
stdInPipeName
);
childProcess
.
stdin
=
<
any
>
net
.
connect
(
stdInPipeName
);
// From now on the childProcess.stdout is available for reading
// From now on the childProcess.stdout is available for reading
childProcess
.
stdout
=
st
dOutSt
ream
;
childProcess
.
stdout
=
stream
;
resolve
(
childProcess
);
resolve
(
childProcess
);
});
});
});
});
s
tdOutS
erver
.
listen
(
stdOutPipeName
);
server
.
listen
(
stdOutPipeName
);
var
serverClosed
=
false
;
var
serverClosed
=
false
;
var
closeServer
=
()
=>
{
var
closeServer
=
()
=>
{
...
@@ -110,8 +100,7 @@ export function fork(modulePath: string, args: string[], options: IForkOptions,
...
@@ -110,8 +100,7 @@ export function fork(modulePath: string, args: string[], options: IForkOptions,
return
;
return
;
}
}
serverClosed
=
true
;
serverClosed
=
true
;
stdOutServer
.
close
();
server
.
close
();
stdErrServer
.
close
();
};
};
// Create the process
// Create the process
...
...
extensions/typescript/src/utils/electronForkStart.ts
浏览文件 @
0a03c66c
...
@@ -26,11 +26,9 @@ var log = (function() {
...
@@ -26,11 +26,9 @@ var log = (function() {
var
stdInPipeName
=
process
.
env
[
'
STDIN_PIPE_NAME
'
];
var
stdInPipeName
=
process
.
env
[
'
STDIN_PIPE_NAME
'
];
var
stdOutPipeName
=
process
.
env
[
'
STDOUT_PIPE_NAME
'
];
var
stdOutPipeName
=
process
.
env
[
'
STDOUT_PIPE_NAME
'
];
var
stdErrPipeName
=
process
.
env
[
'
STDERR_PIPE_NAME
'
];
log
(
'
STDIN_PIPE_NAME:
'
+
stdInPipeName
);
log
(
'
STDIN_PIPE_NAME:
'
+
stdInPipeName
);
log
(
'
STDOUT_PIPE_NAME:
'
+
stdOutPipeName
);
log
(
'
STDOUT_PIPE_NAME:
'
+
stdOutPipeName
);
log
(
'
STDERR_PIPE_NAME:
'
+
stdErrPipeName
);
log
(
'
ATOM_SHELL_INTERNAL_RUN_AS_NODE:
'
+
process
.
env
[
'
ATOM_SHELL_INTERNAL_RUN_AS_NODE
'
]);
log
(
'
ATOM_SHELL_INTERNAL_RUN_AS_NODE:
'
+
process
.
env
[
'
ATOM_SHELL_INTERNAL_RUN_AS_NODE
'
]);
// stdout redirection to named pipe
// stdout redirection to named pipe
...
@@ -46,14 +44,8 @@ log('ATOM_SHELL_INTERNAL_RUN_AS_NODE: ' + process.env['ATOM_SHELL_INTERNAL_RUN_A
...
@@ -46,14 +44,8 @@ log('ATOM_SHELL_INTERNAL_RUN_AS_NODE: ' + process.env['ATOM_SHELL_INTERNAL_RUN_A
// handle process.stdout
// handle process.stdout
(
<
any
>
process
).
__defineGetter__
(
'
stdout
'
,
function
()
{
return
stdOutStream
;
});
(
<
any
>
process
).
__defineGetter__
(
'
stdout
'
,
function
()
{
return
stdOutStream
;
});
// Create a writing stream to the stderr pipe
var
stdErrStream
=
net
.
connect
(
stdErrPipeName
);
// unref stdErrStream to behave like a normal standard out
stdErrStream
.
unref
();
// handle process.stderr
// handle process.stderr
(
<
any
>
process
).
__defineGetter__
(
'
stderr
'
,
function
()
{
return
std
Err
Stream
;
});
(
<
any
>
process
).
__defineGetter__
(
'
stderr
'
,
function
()
{
return
std
Out
Stream
;
});
var
fsWriteSyncString
=
function
(
fd
,
str
,
position
,
encoding
)
{
var
fsWriteSyncString
=
function
(
fd
,
str
,
position
,
encoding
)
{
// fs.writeSync(fd, string[, position[, encoding]]);
// fs.writeSync(fd, string[, position[, encoding]]);
...
@@ -87,18 +79,14 @@ log('ATOM_SHELL_INTERNAL_RUN_AS_NODE: ' + process.env['ATOM_SHELL_INTERNAL_RUN_A
...
@@ -87,18 +79,14 @@ log('ATOM_SHELL_INTERNAL_RUN_AS_NODE: ' + process.env['ATOM_SHELL_INTERNAL_RUN_A
slicedBuffer
=
buffer
.
slice
(
off
,
off
+
len
);
slicedBuffer
=
buffer
.
slice
(
off
,
off
+
len
);
}
}
if
(
fd
===
1
)
{
stdOutStream
.
write
(
slicedBuffer
);
stdOutStream
.
write
(
slicedBuffer
);
}
else
{
stdErrStream
.
write
(
slicedBuffer
);
}
return
slicedBuffer
.
length
;
return
slicedBuffer
.
length
;
};
};
// handle fs.writeSync(1, ...)
// handle fs.writeSync(1, ...)
var
originalWriteSync
=
fs
.
writeSync
;
var
originalWriteSync
=
fs
.
writeSync
;
fs
.
writeSync
=
function
(
fd
,
data
,
position
,
encoding
)
{
fs
.
writeSync
=
function
(
fd
,
data
,
position
,
encoding
)
{
if
(
fd
!==
1
||
fd
!==
2
)
{
if
(
fd
!==
1
)
{
return
originalWriteSync
.
apply
(
fs
,
arguments
);
return
originalWriteSync
.
apply
(
fs
,
arguments
);
}
}
// usage:
// usage:
...
@@ -146,7 +134,6 @@ log('ATOM_SHELL_INTERNAL_RUN_AS_NODE: ' + process.env['ATOM_SHELL_INTERNAL_RUN_A
...
@@ -146,7 +134,6 @@ log('ATOM_SHELL_INTERNAL_RUN_AS_NODE: ' + process.env['ATOM_SHELL_INTERNAL_RUN_A
// Unset the custom environmental variables that should not get inherited
// Unset the custom environmental variables that should not get inherited
delete
process
.
env
[
'
STDIN_PIPE_NAME
'
];
delete
process
.
env
[
'
STDIN_PIPE_NAME
'
];
delete
process
.
env
[
'
STDOUT_PIPE_NAME
'
];
delete
process
.
env
[
'
STDOUT_PIPE_NAME
'
];
delete
process
.
env
[
'
STDERR_PIPE_NAME
'
];
delete
process
.
env
[
'
ATOM_SHELL_INTERNAL_RUN_AS_NODE
'
];
delete
process
.
env
[
'
ATOM_SHELL_INTERNAL_RUN_AS_NODE
'
];
require
(
program
);
require
(
program
);
...
...
src/vs/base/node/stdFork.ts
浏览文件 @
0a03c66c
...
@@ -38,7 +38,7 @@ function generatePipeName(): string {
...
@@ -38,7 +38,7 @@ function generatePipeName(): string {
return
path
.
join
(
os
.
tmpdir
(),
randomName
+
'
.sock
'
);
return
path
.
join
(
os
.
tmpdir
(),
randomName
+
'
.sock
'
);
}
}
function
generatePatchedEnv
(
env
:
any
,
stdInPipeName
:
string
,
stdOutPipeName
:
string
,
stdErrPipeName
:
string
):
any
{
function
generatePatchedEnv
(
env
:
any
,
stdInPipeName
:
string
,
stdOutPipeName
:
string
):
any
{
// Set the two unique pipe names and the electron flag as process env
// Set the two unique pipe names and the electron flag as process env
let
newEnv
:
any
=
{};
let
newEnv
:
any
=
{};
...
@@ -48,7 +48,6 @@ function generatePatchedEnv(env:any, stdInPipeName:string, stdOutPipeName:string
...
@@ -48,7 +48,6 @@ function generatePatchedEnv(env:any, stdInPipeName:string, stdOutPipeName:string
newEnv
[
'
STDIN_PIPE_NAME
'
]
=
stdInPipeName
;
newEnv
[
'
STDIN_PIPE_NAME
'
]
=
stdInPipeName
;
newEnv
[
'
STDOUT_PIPE_NAME
'
]
=
stdOutPipeName
;
newEnv
[
'
STDOUT_PIPE_NAME
'
]
=
stdOutPipeName
;
newEnv
[
'
STDERR_PIPE_NAME
'
]
=
stdErrPipeName
;
newEnv
[
'
ATOM_SHELL_INTERNAL_RUN_AS_NODE
'
]
=
'
1
'
;
newEnv
[
'
ATOM_SHELL_INTERNAL_RUN_AS_NODE
'
]
=
'
1
'
;
return
newEnv
;
return
newEnv
;
...
@@ -72,37 +71,29 @@ export function fork(modulePath: string, args: string[], options: IForkOpts, cal
...
@@ -72,37 +71,29 @@ export function fork(modulePath: string, args: string[], options: IForkOpts, cal
callback
(
err
,
null
);
callback
(
err
,
null
);
};
};
// Generate t
hree
unique pipe names
// Generate t
wo
unique pipe names
let
stdInPipeName
=
generatePipeName
();
let
stdInPipeName
=
generatePipeName
();
let
stdOutPipeName
=
generatePipeName
();
let
stdOutPipeName
=
generatePipeName
();
let
stdErrPipeName
=
generatePipeName
();
let
newEnv
=
generatePatchedEnv
(
options
.
env
||
process
.
env
,
stdInPipeName
,
stdOutPipeName
,
stdErrPipeName
);
let
newEnv
=
generatePatchedEnv
(
options
.
env
||
process
.
env
,
stdInPipeName
,
stdOutPipeName
);
let
childProcess
:
cp
.
ChildProcess
;
let
childProcess
:
cp
.
ChildProcess
;
// Begin listening to stderr pipe
let
stdErrServer
=
net
.
createServer
((
stdErrStream
)
=>
{
// From now on the childProcess.stderr is available for reading
childProcess
.
stderr
=
stdErrStream
;
});
stdErrServer
.
listen
(
stdErrPipeName
);
// Begin listening to stdout pipe
// Begin listening to stdout pipe
let
s
tdOutServer
=
net
.
createServer
((
stdOutS
tream
)
=>
{
let
s
erver
=
net
.
createServer
((
s
tream
)
=>
{
// The child process will write exactly one chunk with content `ready` when it has installed a listener to the stdin pipe
// The child process will write exactly one chunk with content `ready` when it has installed a listener to the stdin pipe
st
dOutSt
ream
.
once
(
'
data
'
,
(
chunk
:
Buffer
)
=>
{
stream
.
once
(
'
data
'
,
(
chunk
:
Buffer
)
=>
{
// The child process is sending me the `ready` chunk, time to connect to the stdin pipe
// The child process is sending me the `ready` chunk, time to connect to the stdin pipe
childProcess
.
stdin
=
<
any
>
net
.
connect
(
stdInPipeName
);
childProcess
.
stdin
=
<
any
>
net
.
connect
(
stdInPipeName
);
// From now on the childProcess.stdout is available for reading
// From now on the childProcess.stdout is available for reading
childProcess
.
stdout
=
st
dOutSt
ream
;
childProcess
.
stdout
=
stream
;
resolve
(
childProcess
);
resolve
(
childProcess
);
});
});
});
});
s
tdOutS
erver
.
listen
(
stdOutPipeName
);
server
.
listen
(
stdOutPipeName
);
let
serverClosed
=
false
;
let
serverClosed
=
false
;
let
closeServer
=
()
=>
{
let
closeServer
=
()
=>
{
...
@@ -110,8 +101,7 @@ export function fork(modulePath: string, args: string[], options: IForkOpts, cal
...
@@ -110,8 +101,7 @@ export function fork(modulePath: string, args: string[], options: IForkOpts, cal
return
;
return
;
}
}
serverClosed
=
true
;
serverClosed
=
true
;
stdOutServer
.
close
();
server
.
close
();
stdErrServer
.
close
();
};
};
// Create the process
// Create the process
...
...
src/vs/base/node/stdForkStart.js
浏览文件 @
0a03c66c
...
@@ -28,11 +28,9 @@ var log = (function() {
...
@@ -28,11 +28,9 @@ var log = (function() {
var
stdInPipeName
=
process
.
env
[
'
STDIN_PIPE_NAME
'
];
var
stdInPipeName
=
process
.
env
[
'
STDIN_PIPE_NAME
'
];
var
stdOutPipeName
=
process
.
env
[
'
STDOUT_PIPE_NAME
'
];
var
stdOutPipeName
=
process
.
env
[
'
STDOUT_PIPE_NAME
'
];
var
stdErrPipeName
=
process
.
env
[
'
STDERR_PIPE_NAME
'
];
log
(
'
STDIN_PIPE_NAME:
'
+
stdInPipeName
);
log
(
'
STDIN_PIPE_NAME:
'
+
stdInPipeName
);
log
(
'
STDOUT_PIPE_NAME:
'
+
stdOutPipeName
);
log
(
'
STDOUT_PIPE_NAME:
'
+
stdOutPipeName
);
log
(
'
STDERR_PIPE_NAME:
'
+
stdErrPipeName
);
log
(
'
ATOM_SHELL_INTERNAL_RUN_AS_NODE:
'
+
process
.
env
[
'
ATOM_SHELL_INTERNAL_RUN_AS_NODE
'
]);
log
(
'
ATOM_SHELL_INTERNAL_RUN_AS_NODE:
'
+
process
.
env
[
'
ATOM_SHELL_INTERNAL_RUN_AS_NODE
'
]);
// stdout redirection to named pipe
// stdout redirection to named pipe
...
@@ -48,14 +46,8 @@ log('ATOM_SHELL_INTERNAL_RUN_AS_NODE: ' + process.env['ATOM_SHELL_INTERNAL_RUN_A
...
@@ -48,14 +46,8 @@ log('ATOM_SHELL_INTERNAL_RUN_AS_NODE: ' + process.env['ATOM_SHELL_INTERNAL_RUN_A
// handle process.stdout
// handle process.stdout
process
.
__defineGetter__
(
'
stdout
'
,
function
()
{
return
stdOutStream
;
});
process
.
__defineGetter__
(
'
stdout
'
,
function
()
{
return
stdOutStream
;
});
// Create a writing stream to the stderr pipe
var
stdErrStream
=
net
.
connect
(
stdErrPipeName
);
// unref stdErrStream to behave like a normal standard out
stdErrStream
.
unref
();
// handle process.stderr
// handle process.stderr
process
.
__defineGetter__
(
'
stderr
'
,
function
()
{
return
std
Err
Stream
;
});
process
.
__defineGetter__
(
'
stderr
'
,
function
()
{
return
std
Out
Stream
;
});
var
fsWriteSyncString
=
function
(
fd
,
str
,
position
,
encoding
)
{
var
fsWriteSyncString
=
function
(
fd
,
str
,
position
,
encoding
)
{
// fs.writeSync(fd, string[, position[, encoding]]);
// fs.writeSync(fd, string[, position[, encoding]]);
...
@@ -89,18 +81,14 @@ log('ATOM_SHELL_INTERNAL_RUN_AS_NODE: ' + process.env['ATOM_SHELL_INTERNAL_RUN_A
...
@@ -89,18 +81,14 @@ log('ATOM_SHELL_INTERNAL_RUN_AS_NODE: ' + process.env['ATOM_SHELL_INTERNAL_RUN_A
slicedBuffer
=
buffer
.
slice
(
off
,
off
+
len
);
slicedBuffer
=
buffer
.
slice
(
off
,
off
+
len
);
}
}
if
(
fd
===
1
)
{
stdOutStream
.
write
(
slicedBuffer
);
stdOutStream
.
write
(
slicedBuffer
);
}
else
{
stdErrStream
.
write
(
slicedBuffer
);
}
return
slicedBuffer
.
length
;
return
slicedBuffer
.
length
;
};
};
// handle fs.writeSync(1, ...)
// handle fs.writeSync(1, ...)
var
originalWriteSync
=
fs
.
writeSync
;
var
originalWriteSync
=
fs
.
writeSync
;
fs
.
writeSync
=
function
(
fd
,
data
,
position
,
encoding
)
{
fs
.
writeSync
=
function
(
fd
,
data
,
position
,
encoding
)
{
if
(
fd
!==
1
||
fd
!==
2
)
{
if
(
fd
!==
1
)
{
return
originalWriteSync
.
apply
(
fs
,
arguments
);
return
originalWriteSync
.
apply
(
fs
,
arguments
);
}
}
// usage:
// usage:
...
@@ -148,7 +136,6 @@ log('ATOM_SHELL_INTERNAL_RUN_AS_NODE: ' + process.env['ATOM_SHELL_INTERNAL_RUN_A
...
@@ -148,7 +136,6 @@ log('ATOM_SHELL_INTERNAL_RUN_AS_NODE: ' + process.env['ATOM_SHELL_INTERNAL_RUN_A
// Unset the custom environmental variables that should not get inherited
// Unset the custom environmental variables that should not get inherited
delete
process
.
env
[
'
STDIN_PIPE_NAME
'
];
delete
process
.
env
[
'
STDIN_PIPE_NAME
'
];
delete
process
.
env
[
'
STDOUT_PIPE_NAME
'
];
delete
process
.
env
[
'
STDOUT_PIPE_NAME
'
];
delete
process
.
env
[
'
STDERR_PIPE_NAME
'
];
delete
process
.
env
[
'
ATOM_SHELL_INTERNAL_RUN_AS_NODE
'
];
delete
process
.
env
[
'
ATOM_SHELL_INTERNAL_RUN_AS_NODE
'
];
require
(
program
);
require
(
program
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录