[CRIU] [PATCHv2] log: add gnu-styled output to stdout

Dmitry Safonov dsafonov at virtuozzo.com
Fri Mar 25 05:33:04 PDT 2016


On 03/25/2016 03:29 PM, Dmitry Safonov wrote:
> Before this would open file named '-' as log:
> ./criu/criu dump -t 20526 -o -
> But now it will print log into stdout. Charming.
I guess, it may be easilly dropped, if you want -
because omitting '-o' option will lead to printing
into stderr stream.
But, anyway, someone as me may expect that
'-o' should catch '-' to print to stdout.
>
> Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
> ---
>   criu/log.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/criu/log.c b/criu/log.c
> index 1435401abac5..6c5d807f8cd6 100644
> --- a/criu/log.c
> +++ b/criu/log.c
> @@ -79,7 +79,13 @@ int log_init(const char *output)
>   	gettimeofday(&start, NULL);
>   	reset_buf_off();
>   
> -	if (output) {
> +	if (output && !strncmp(output, "-", 2)) {
> +		new_logfd = dup(STDOUT_FILENO);
> +		if (new_logfd < 0) {
> +			pr_perror("Cant't dup stdout stream");
> +			return -1;
> +		}
> +	} else if (output) {
>   		new_logfd = open(output, O_CREAT|O_TRUNC|O_WRONLY|O_APPEND, 0600);
>   		if (new_logfd < 0) {
>   			pr_perror("Can't create log file %s", output);


-- 
Regards,
Dmitry Safonov



More information about the CRIU mailing list