From c3b9448cf7bd53847cd351fa2da48ef932bd0ea9 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Wed, 20 Nov 2013 14:26:41 +0400 Subject: [PATCH] pidfile: Don't push opts.pidfile as write_pidfile arg opts are criu-wide available. Signed-off-by: Pavel Emelyanov --- cr-restore.c | 2 +- cr-service.c | 2 +- include/log.h | 2 +- log.c | 6 +++--- page-xfer.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cr-restore.c b/cr-restore.c index 27169e79d..7ba42fd3b 100644 --- a/cr-restore.c +++ b/cr-restore.c @@ -987,7 +987,7 @@ static inline int fork_with_pid(struct pstree_item *item) pid = ret; - ret = write_pidfile(opts.pidfile, pid); + ret = write_pidfile(pid); if (ret < 0) { pr_perror("Can't write pidfile"); kill(pid, SIGKILL); diff --git a/cr-service.c b/cr-service.c index 1867b2ee5..b906b3115 100644 --- a/cr-service.c +++ b/cr-service.c @@ -386,7 +386,7 @@ int cr_service(bool daemon_mode) } if (opts.pidfile) { - if (write_pidfile(opts.pidfile, getpid()) == -1) { + if (write_pidfile(getpid()) == -1) { pr_perror("Can't write pidfile"); return -1; } diff --git a/include/log.h b/include/log.h index c9f4412a1..1060254a8 100644 --- a/include/log.h +++ b/include/log.h @@ -19,7 +19,7 @@ extern int vprint_num(char *buf, int blen, int num, char **ps); extern void print_on_level(unsigned int loglevel, const char *format, ...) __attribute__ ((__format__ (__printf__, 2, 3))); -extern int write_pidfile(char *pfname, int pid); +extern int write_pidfile(int pid); #ifndef LOG_PREFIX # define LOG_PREFIX diff --git a/log.c b/log.c index 8a6ed0689..896a7434e 100644 --- a/log.c +++ b/log.c @@ -171,13 +171,13 @@ void print_on_level(unsigned int loglevel, const char *format, ...) va_end(params); } -int write_pidfile(char *pfname, int pid) +int write_pidfile(int pid) { int fd; - fd = open(pfname, O_WRONLY | O_TRUNC | O_CREAT, 0600); + fd = open(opts.pidfile, O_WRONLY | O_TRUNC | O_CREAT, 0600); if (fd == -1) { - pr_perror("Can't open %s", pfname); + pr_perror("Can't open %s", opts.pidfile); return -1; } diff --git a/page-xfer.c b/page-xfer.c index 5ff9c65c8..ff2cda0f5 100644 --- a/page-xfer.c +++ b/page-xfer.c @@ -277,7 +277,7 @@ int cr_page_server(bool daemon_mode) } if (opts.pidfile) { - if (write_pidfile(opts.pidfile, getpid()) == -1) { + if (write_pidfile(getpid()) == -1) { pr_perror("Can't write pidfile"); return -1; }