[CRIU] [PATCH] log: write pidfile at log dir using service_fd

Pavel Emelyanov xemul at parallels.com
Sun Nov 3 01:03:52 PST 2013


On 11/03/2013 04:23 AM, Ruslan Kuprieiev wrote:
> Currently, if we're using -d with --pidfile, we can't use relative pidfile path,
> as service/page-server going daemon before writing pidfile. So lets use service_fd
> to write pidfile at log dir.

Let's better ban relative pidfile paths for --daemon mode to avoid confusion.

> Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
> ---
>  log.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/log.c b/log.c
> index 1e5fcad..3a3184b 100644
> --- a/log.c
> +++ b/log.c
> @@ -194,9 +194,15 @@ void print_on_level(unsigned int loglevel, const char *format, ...)
>  
>  int write_pidfile(char *pfname, int pid)
>  {
> -	int fd;
> +	int fd, dfd;
>  
> -	fd = open(pfname, O_WRONLY | O_TRUNC | O_CREAT, 0600);
> +	dfd = get_service_fd(LOG_DIR_FD_OFF);
> +	if (dfd < 0) {
> +		pr_perror("Log directory isn't initiated");
> +		return -1;
> +	}
> +
> +	fd = openat(dfd, pfname, O_WRONLY | O_TRUNC | O_CREAT, 0600);
>  	if (fd == -1) {
>  		pr_perror("Can't open %s", pfname);
>  		kill(pid, SIGKILL);
> 




More information about the CRIU mailing list