Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
77a2fc00
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
77a2fc00
编写于
1月 10, 2008
作者:
M
Mark McLoughlin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add virRun() helper function (Dan Berrange)
上级
9d11255a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
43 addition
and
0 deletion
+43
-0
ChangeLog
ChangeLog
+4
-0
src/util.c
src/util.c
+38
-0
src/util.h
src/util.h
+1
-0
未找到文件。
ChangeLog
浏览文件 @
77a2fc00
Thu Jan 10 13:44:17 GMT 2008 Mark McLoughlin <markmc@redhat.com>
* src/util.[ch]: Add virRun() helper function (Dan Berrange)
Wed Jan 9 16:04:00 EST 2008 Daniel P. Berrange <berrange@redhat.com>
* src/xen_internal.c: Ensure cpumap is at least 8 bytes long
...
...
src/util.c
浏览文件 @
77a2fc00
...
...
@@ -33,6 +33,7 @@
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <string.h>
#ifdef HAVE_PATHS_H
...
...
@@ -203,6 +204,43 @@ virExecNonBlock(virConnectPtr conn,
return
(
_virExec
(
conn
,
argv
,
retpid
,
infd
,
outfd
,
errfd
,
1
));
}
/**
* @conn connection to report errors against
* @argv NULL terminated argv to run
* @status optional variable to return exit status in
*
* Run a command without using the shell.
*
* If status is NULL, then return 0 if the command run and
* exited with 0 status; Otherwise return -1
*
* If status is not-NULL, then return 0 if the command ran.
* The status variable is filled with the command exit status
* and should be checked by caller for success. Return -1
* only if the command could not be run.
*/
int
virRun
(
virConnectPtr
conn
,
char
**
argv
,
int
*
status
)
{
int
childpid
,
exitstatus
,
ret
;
if
((
ret
=
virExec
(
conn
,
argv
,
&
childpid
,
-
1
,
NULL
,
NULL
))
<
0
)
return
ret
;
while
((
ret
=
waitpid
(
childpid
,
&
exitstatus
,
0
)
==
-
1
)
&&
errno
==
EINTR
);
if
(
ret
==
-
1
)
return
-
1
;
if
(
status
==
NULL
)
{
errno
=
EINVAL
;
return
(
WIFEXITED
(
exitstatus
)
&&
WEXITSTATUS
(
exitstatus
)
==
0
)
?
0
:
-
1
;
}
else
{
*
status
=
exitstatus
;
return
0
;
}
}
#else
/* __MINGW32__ */
int
...
...
src/util.h
浏览文件 @
77a2fc00
...
...
@@ -28,6 +28,7 @@
int
virExec
(
virConnectPtr
conn
,
char
**
argv
,
int
*
retpid
,
int
infd
,
int
*
outfd
,
int
*
errfd
);
int
virExecNonBlock
(
virConnectPtr
conn
,
char
**
argv
,
int
*
retpid
,
int
infd
,
int
*
outfd
,
int
*
errfd
);
int
virRun
(
virConnectPtr
conn
,
char
**
argv
,
int
*
status
);
int
saferead
(
int
fd
,
void
*
buf
,
size_t
count
);
ssize_t
safewrite
(
int
fd
,
const
void
*
buf
,
size_t
count
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录