qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] os-posix: Log to logfile in case of daemonize


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH] os-posix: Log to logfile in case of daemonize
Date: Mon, 8 Feb 2016 10:29:55 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0


On 16/12/2015 17:56, Alex Pyrgiotis wrote:
> +
> +        log = qemu_get_log_filename();
> +        if (log != NULL) {
> +            TFR(fd = qemu_open(log, O_RDWR | O_APPEND | O_CREAT, 0640));

Here you are opening the same file twice, but the FILE* that is opened
in do_qemu_set_log does not necessarily have O_APPEND.

I like the idea of moving stderr to the logfile, but I'm not sure how to
do it.  For now, can you prepare a simple patch that only does the "dup"
if "isatty" returns true for the file descriptor?  This lets you use
redirection at the shell level to save the stdout and stderr.

Paolo

> +        } else {
> +            TFR(fd = qemu_open("/dev/null", O_RDWR));
> +        }
>          if (fd == -1) {
> +            fprintf(stderr, "Cannot open \"%s\" for logging\n", log);
>              exit(1);
>          }
> +        g_free(log);
>      }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]