aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/libxl_exec.c
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2010-04-12 17:42:29 +0100
committerKeir Fraser <keir.fraser@citrix.com>2010-04-12 17:42:29 +0100
commit1d95423e86a664f2c9488d8ffc29a0a83eed68b8 (patch)
tree600fb2eef74fae8f61d3abe6705224129c243a12 /tools/libxl/libxl_exec.c
parentaa8978e2d94470c0563f91df4c504446df82b9c6 (diff)
downloadxen-1d95423e86a664f2c9488d8ffc29a0a83eed68b8.tar.gz
xen-1d95423e86a664f2c9488d8ffc29a0a83eed68b8.tar.bz2
xen-1d95423e86a664f2c9488d8ffc29a0a83eed68b8.zip
libxl: Expose libxl_report_exitstatus
xl would like to use libxl_report_exitstatus, so expose it in libxl_utils.h to avoid having to write it twice. Also, give it a "level" argument to set the loglevel of the resulting message. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxl/libxl_exec.c')
-rw-r--r--tools/libxl/libxl_exec.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/tools/libxl/libxl_exec.c b/tools/libxl/libxl_exec.c
index 6d4a5c5115..52dda97f5b 100644
--- a/tools/libxl/libxl_exec.c
+++ b/tools/libxl/libxl_exec.c
@@ -57,34 +57,32 @@ void libxl_exec(int stdinfd, int stdoutfd, int stderrfd, char *arg0, char **args
_exit(-1);
}
-void libxl_report_child_exitstatus(struct libxl_ctx *ctx,
+void libxl_report_child_exitstatus(struct libxl_ctx *ctx, int level,
const char *what, pid_t pid, int status)
{
- /* treats all exit statuses as errors; if that's not what you want,
- * check status yourself first */
if (WIFEXITED(status)) {
int st = WEXITSTATUS(status);
if (st)
- XL_LOG(ctx, XL_LOG_ERROR, "%s [%ld] exited"
+ XL_LOG(ctx, level, "%s [%ld] exited"
" with error status %d", what, (unsigned long)pid, st);
else
- XL_LOG(ctx, XL_LOG_ERROR, "%s [%ld] unexpectedly"
+ XL_LOG(ctx, level, "%s [%ld] unexpectedly"
" exited status zero", what, (unsigned long)pid);
} else if (WIFSIGNALED(status)) {
int sig = WTERMSIG(status);
const char *str = strsignal(sig);
const char *coredump = WCOREDUMP(status) ? " (core dumped)" : "";
if (str)
- XL_LOG(ctx, XL_LOG_ERROR, "%s [%ld] died due to"
+ XL_LOG(ctx, level, "%s [%ld] died due to"
" fatal signal %s%s", what, (unsigned long)pid,
str, coredump);
else
- XL_LOG(ctx, XL_LOG_ERROR, "%s [%ld] died due to unknown"
+ XL_LOG(ctx, level, "%s [%ld] died due to unknown"
" fatal signal number %d%s", what, (unsigned long)pid,
sig, coredump);
} else {
- XL_LOG(ctx, XL_LOG_ERROR, "%s [%ld] gave unknown"
+ XL_LOG(ctx, level, "%s [%ld] gave unknown"
" wait status 0x%x", what, (unsigned long)pid, status);
}
}
@@ -145,7 +143,7 @@ static void report_spawn_intermediate_status(struct libxl_ctx *ctx,
char *intermediate_what = libxl_sprintf(ctx,
"%s intermediate process (startup monitor)",
for_spawn->what);
- libxl_report_child_exitstatus(ctx, intermediate_what,
+ libxl_report_child_exitstatus(ctx, XL_LOG_ERROR, intermediate_what,
for_spawn->intermediate, status);
}
}