mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
libct/nsenter/nsexec.c: improve bail
This makes it possible to use bail() even if logging is not set up (yet), so we don't have to think whether it's OK to use it or not. In addition, this might help some unit tests that do not set log forwarding. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -182,10 +182,14 @@ out:
|
||||
/* XXX: This is ugly. */
|
||||
static int syncfd = -1;
|
||||
|
||||
#define bail(fmt, ...) \
|
||||
do { \
|
||||
write_log(FATAL, fmt ": %m", ##__VA_ARGS__); \
|
||||
exit(1); \
|
||||
#define bail(fmt, ...) \
|
||||
do { \
|
||||
if (logfd < 0) \
|
||||
fprintf(stderr, "FATAL: " fmt ": %m\n", \
|
||||
##__VA_ARGS__); \
|
||||
else \
|
||||
write_log(FATAL, fmt ": %m", ##__VA_ARGS__); \
|
||||
exit(1); \
|
||||
} while(0)
|
||||
|
||||
static int write_file(char *data, size_t data_len, char *pathfmt, ...)
|
||||
@@ -407,9 +411,7 @@ static void setup_logpipe(void)
|
||||
|
||||
logfd = strtol(logpipe, &endptr, 10);
|
||||
if (logpipe == endptr || *endptr != '\0') {
|
||||
fprintf(stderr, "unable to parse _LIBCONTAINER_LOGPIPE, value: %s\n", logpipe);
|
||||
/* It is too early to use bail */
|
||||
exit(1);
|
||||
bail("unable to parse _LIBCONTAINER_LOGPIPE, value: %s", logpipe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user