Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
4b2133de
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4b2133de
编写于
8月 04, 2009
作者:
M
martin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6856590: (process) Use RESTARTABLE in UNIXProcess_md.c
Summary: Wrap all system calls with RESTARTABLE Reviewed-by: michaelm
上级
b8e20275
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
70 addition
and
29 deletion
+70
-29
src/solaris/native/java/lang/UNIXProcess_md.c
src/solaris/native/java/lang/UNIXProcess_md.c
+70
-29
未找到文件。
src/solaris/native/java/lang/UNIXProcess_md.c
浏览文件 @
4b2133de
...
...
@@ -140,6 +140,13 @@
#define FAIL_FILENO (STDERR_FILENO + 1)
/* TODO: Refactor. */
#define RESTARTABLE(_cmd, _result) do { \
do { \
_result = _cmd; \
} while((_result == -1) && (errno == EINTR)); \
} while(0)
/* This is one of the rare times it's more portable to declare an
* external symbol explicitly, rather than via a system header.
* The declaration is standardized as part of UNIX98, but there is
...
...
@@ -342,6 +349,36 @@ Java_java_lang_UNIXProcess_waitForProcessExit(JNIEnv* env,
}
}
static
ssize_t
restartableWrite
(
int
fd
,
const
void
*
buf
,
size_t
count
)
{
ssize_t
result
;
RESTARTABLE
(
write
(
fd
,
buf
,
count
),
result
);
return
result
;
}
static
int
restartableDup2
(
int
fd_from
,
int
fd_to
)
{
int
err
;
RESTARTABLE
(
dup2
(
fd_from
,
fd_to
),
err
);
return
err
;
}
static
int
restartableClose
(
int
fd
)
{
int
err
;
RESTARTABLE
(
close
(
fd
),
err
);
return
err
;
}
static
int
closeSafely
(
int
fd
)
{
return
(
fd
==
-
1
)
?
0
:
restartableClose
(
fd
);
}
static
int
isAsciiDigit
(
char
c
)
{
...
...
@@ -362,8 +399,8 @@ closeDescriptors(void)
* the lowest numbered file descriptor, just like open(). So we
* close a couple explicitly. */
close
(
from_fd
);
/* for possible use by opendir() */
close
(
from_fd
+
1
);
/* another one for good luck */
restartableClose
(
from_fd
);
/* for possible use by opendir() */
restartableClose
(
from_fd
+
1
);
/* another one for good luck */
if
((
dp
=
opendir
(
"/proc/self/fd"
))
==
NULL
)
return
0
;
...
...
@@ -375,7 +412,7 @@ closeDescriptors(void)
int
fd
;
if
(
isAsciiDigit
(
dirp
->
d_name
[
0
])
&&
(
fd
=
strtol
(
dirp
->
d_name
,
NULL
,
10
))
>=
from_fd
+
2
)
c
lose
(
fd
);
restartableC
lose
(
fd
);
}
closedir
(
dp
);
...
...
@@ -383,13 +420,15 @@ closeDescriptors(void)
return
1
;
}
static
void
static
int
moveDescriptor
(
int
fd_from
,
int
fd_to
)
{
if
(
fd_from
!=
fd_to
)
{
dup2
(
fd_from
,
fd_to
);
close
(
fd_from
);
if
((
restartableDup2
(
fd_from
,
fd_to
)
==
-
1
)
||
(
restartableClose
(
fd_from
)
==
-
1
))
return
-
1
;
}
return
0
;
}
static
const
char
*
...
...
@@ -586,13 +625,6 @@ JDK_execvpe(const char *file,
}
}
static
void
closeSafely
(
int
fd
)
{
if
(
fd
!=
-
1
)
close
(
fd
);
}
/*
* Reads nbyte bytes from file descriptor fd into buf,
* The read operation is retried in case of EINTR or partial reads.
...
...
@@ -661,31 +693,40 @@ childProcess(void *arg)
/* Close the parent sides of the pipes.
Closing pipe fds here is redundant, since closeDescriptors()
would do it anyways, but a little paranoia is a good thing. */
closeSafely
(
p
->
in
[
1
]);
closeSafely
(
p
->
out
[
0
]);
closeSafely
(
p
->
err
[
0
]);
closeSafely
(
p
->
fail
[
0
]);
if
((
closeSafely
(
p
->
in
[
1
])
==
-
1
)
||
(
closeSafely
(
p
->
out
[
0
])
==
-
1
)
||
(
closeSafely
(
p
->
err
[
0
])
==
-
1
)
||
(
closeSafely
(
p
->
fail
[
0
])
==
-
1
))
goto
WhyCantJohnnyExec
;
/* Give the child sides of the pipes the right fileno's. */
/* Note: it is possible for in[0] == 0 */
moveDescriptor
(
p
->
in
[
0
]
!=
-
1
?
p
->
in
[
0
]
:
p
->
fds
[
0
],
STDIN_FILENO
);
moveDescriptor
(
p
->
out
[
1
]
!=
-
1
?
p
->
out
[
1
]
:
p
->
fds
[
1
],
STDOUT_FILENO
);
if
((
moveDescriptor
(
p
->
in
[
0
]
!=
-
1
?
p
->
in
[
0
]
:
p
->
fds
[
0
],
STDIN_FILENO
)
==
-
1
)
||
(
moveDescriptor
(
p
->
out
[
1
]
!=
-
1
?
p
->
out
[
1
]
:
p
->
fds
[
1
],
STDOUT_FILENO
)
==
-
1
))
goto
WhyCantJohnnyExec
;
if
(
p
->
redirectErrorStream
)
{
closeSafely
(
p
->
err
[
1
]);
dup2
(
STDOUT_FILENO
,
STDERR_FILENO
);
if
((
closeSafely
(
p
->
err
[
1
])
==
-
1
)
||
(
restartableDup2
(
STDOUT_FILENO
,
STDERR_FILENO
)
==
-
1
))
goto
WhyCantJohnnyExec
;
}
else
{
moveDescriptor
(
p
->
err
[
1
]
!=
-
1
?
p
->
err
[
1
]
:
p
->
fds
[
2
],
STDERR_FILENO
);
if
(
moveDescriptor
(
p
->
err
[
1
]
!=
-
1
?
p
->
err
[
1
]
:
p
->
fds
[
2
],
STDERR_FILENO
)
==
-
1
)
goto
WhyCantJohnnyExec
;
}
moveDescriptor
(
p
->
fail
[
1
],
FAIL_FILENO
);
if
(
moveDescriptor
(
p
->
fail
[
1
],
FAIL_FILENO
)
==
-
1
)
goto
WhyCantJohnnyExec
;
/* close everything */
if
(
closeDescriptors
()
==
0
)
{
/* failed, close the old way */
int
max_fd
=
(
int
)
sysconf
(
_SC_OPEN_MAX
);
int
i
;
for
(
i
=
FAIL_FILENO
+
1
;
i
<
max_fd
;
i
++
)
close
(
i
);
int
fd
;
for
(
fd
=
FAIL_FILENO
+
1
;
fd
<
max_fd
;
fd
++
)
if
(
restartableClose
(
fd
)
==
-
1
&&
errno
!=
EBADF
)
goto
WhyCantJohnnyExec
;
}
/* change to the new working directory */
...
...
@@ -710,9 +751,9 @@ childProcess(void *arg)
*/
{
int
errnum
=
errno
;
w
rite
(
FAIL_FILENO
,
&
errnum
,
sizeof
(
errnum
));
restartableW
rite
(
FAIL_FILENO
,
&
errnum
,
sizeof
(
errnum
));
}
c
lose
(
FAIL_FILENO
);
restartableC
lose
(
FAIL_FILENO
);
_exit
(
-
1
);
return
0
;
/* Suppress warning "no return value from function" */
}
...
...
@@ -847,7 +888,7 @@ Java_java_lang_UNIXProcess_forkAndExec(JNIEnv *env,
goto
Catch
;
}
c
lose
(
fail
[
1
]);
fail
[
1
]
=
-
1
;
/* See: WhyCantJohnnyExec */
restartableC
lose
(
fail
[
1
]);
fail
[
1
]
=
-
1
;
/* See: WhyCantJohnnyExec */
switch
(
readFully
(
fail
[
0
],
&
errnum
,
sizeof
(
errnum
)))
{
case
0
:
break
;
/* Exec succeeded */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录