[CRIU] Re: [PATCH cr 2/4] crtools: make to be able to split messages by pid

Pavel Emelyanov xemul at parallels.com
Thu May 3 05:06:06 EDT 2012


> @@ -97,6 +117,16 @@ void print_on_level(unsigned int loglevel, const char *format, ...)
>  	}
>  
>  	va_start(params, format);
> -	vdprintf(fd, format, params);
> +	size = vsnprintf(buffer + buf_off, PAGE_SIZE - buf_off, format, params);
>  	va_end(params);
> +
> +	size += buf_off;
> +
> +	off = 0;
> +	while (off < size) {
> +		ret = write(fd, buffer + off, size - off);
> +		if (ret <= 0)
> +			break;
> +		off += ret;
> +	}

Isn't it easier to do

vdprintf(fd, "%6d: ", getpid());
vdprintf(fd, format, params);

?

>  }


More information about the CRIU mailing list