2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00

crtools: add options to specified a log file

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
This commit is contained in:
Andrey Vagin
2011-12-08 18:39:00 +04:00
committed by Cyrill Gorcunov
parent ecc2776fc9
commit 650318f4b2
3 changed files with 22 additions and 7 deletions

13
util.c
View File

@@ -42,9 +42,18 @@
static int logfd = STDERR_FILENO;
int init_logging(void)
int init_logging(const char *name)
{
struct rlimit rlimit;
int fd = STDERR_FILENO;
if (name) {
fd = open(name, O_CREAT | O_WRONLY);
if (fd == -1) {
pr_perror("Can't create log file %s\n", name);
return 1;
}
}
if (getrlimit(RLIMIT_NOFILE, &rlimit)) {
pr_err("can't get rlimit: %m\n");
@@ -52,7 +61,7 @@ int init_logging(void)
}
logfd = rlimit.rlim_cur - 1;
if (dup2(2, logfd) < 0) {
if (dup2(fd, logfd) < 0) {
pr_err("can't duplicate descriptor 2->%d: %m\n", logfd);
return 1;
}