Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
野花太放肆
jenkins
提交
3f4d01ec
J
jenkins
项目概览
野花太放肆
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3f4d01ec
编写于
8月 25, 2011
作者:
K
Kohsuke Kawaguchi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[JENKINS-8856] evacuate stdout at OS level to avoid interference with
JVM.
上级
9c9379e9
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
75 addition
and
1 deletion
+75
-1
changelog.html
changelog.html
+3
-0
core/src/main/java/hudson/util/jna/GNUCLibrary.java
core/src/main/java/hudson/util/jna/GNUCLibrary.java
+4
-0
core/src/main/java/jenkins/slaves/StandardOutputSwapper.java
core/src/main/java/jenkins/slaves/StandardOutputSwapper.java
+67
-0
pom.xml
pom.xml
+1
-1
未找到文件。
changelog.html
浏览文件 @
3f4d01ec
...
...
@@ -67,6 +67,9 @@ Upcoming changes</a>
<li
class=
bug
>
Jenkins didn't start on IBM JDK.
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-10810"
>
issue 10810
</a>
)
<li
class=
rfe
>
stdin/stdout based remote slaves, such as ones launched via SSH or script, now does a better redirect to avoid interference with JVM output to stdout.
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-8856"
>
issue 8856
</a>
)
</ul>
</div>
<!--=TRUNK-END=-->
...
...
core/src/main/java/hudson/util/jna/GNUCLibrary.java
浏览文件 @
3f4d01ec
...
...
@@ -72,6 +72,10 @@ public interface GNUCLibrary extends Library {
int
chown
(
String
fileName
,
int
uid
,
int
gid
);
int
chmod
(
String
fileName
,
int
i
);
int
dup
(
int
old
);
int
dup2
(
int
old
,
int
_new
);
int
close
(
int
fd
);
// see http://www.gnu.org/s/libc/manual/html_node/Renaming-Files.html
int
rename
(
String
oldname
,
String
newname
);
...
...
core/src/main/java/jenkins/slaves/StandardOutputSwapper.java
0 → 100644
浏览文件 @
3f4d01ec
package
jenkins.slaves
;
import
hudson.Extension
;
import
hudson.FilePath
;
import
hudson.model.Computer
;
import
hudson.model.TaskListener
;
import
hudson.remoting.Callable
;
import
hudson.remoting.Channel
;
import
hudson.remoting.StandardOutputStream
;
import
hudson.slaves.ComputerListener
;
import
hudson.util.jna.GNUCLibrary
;
import
java.io.File
;
import
java.io.FileDescriptor
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.lang.reflect.Constructor
;
import
java.util.logging.Logger
;
/**
* @author Kohsuke Kawaguchi
*/
@Extension
public
class
StandardOutputSwapper
extends
ComputerListener
{
@Override
public
void
preOnline
(
Computer
c
,
Channel
channel
,
FilePath
root
,
TaskListener
listener
)
{
if
(
disabled
)
return
;
try
{
if
(
channel
.
call
(
new
ChannelSwapper
()))
listener
.
getLogger
().
println
(
"Evacuated stdout"
);
}
catch
(
Throwable
e
)
{
LOGGER
.
fine
(
"Fatal problem swapping file descriptors "
+
c
.
getName
());
}
}
private
static
final
class
ChannelSwapper
implements
Callable
<
Boolean
,
Exception
>
{
public
Boolean
call
()
throws
Exception
{
if
(
File
.
pathSeparatorChar
==
';'
)
return
false
;
// Windows
OutputStream
o
=
Channel
.
current
().
getUnderlyingOutput
();
if
(
o
instanceof
StandardOutputStream
)
{
StandardOutputStream
stdout
=
(
StandardOutputStream
)
o
;
// duplicate the OS file descriptor and create FileOutputStream around it
int
out
=
GNUCLibrary
.
LIBC
.
dup
(
1
);
if
(
out
<
0
)
throw
new
IOException
(
"Failed to dup(1)"
);
Constructor
<
FileDescriptor
>
c
=
FileDescriptor
.
class
.
getDeclaredConstructor
(
int
.
class
);
c
.
setAccessible
(
true
);
FileOutputStream
fos
=
new
FileOutputStream
(
c
.
newInstance
(
out
));
// swap it into channel so that it'll use the new file descriptor
stdout
.
swap
(
fos
);
// close fd=1 (stdout) and duplicate fd=2 (stderr) into fd=1 (stdout)
GNUCLibrary
.
LIBC
.
close
(
1
);
GNUCLibrary
.
LIBC
.
dup2
(
2
,
1
);
return
true
;
}
return
false
;
}
}
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
StandardOutputSwapper
.
class
.
getName
());
public
static
boolean
disabled
=
Boolean
.
getBoolean
(
StandardOutputSwapper
.
class
.
getName
()+
".disabled"
);
}
pom.xml
浏览文件 @
3f4d01ec
...
...
@@ -133,7 +133,7 @@ THE SOFTWARE.
<dependency>
<groupId>
org.jenkins-ci.main
</groupId>
<artifactId>
remoting
</artifactId>
<version>
2.
4
</version>
<version>
2.
5
</version>
</dependency>
</dependencies>
</dependencyManagement>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录