From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44275) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSi90-0007h2-OT for qemu-devel@nongnu.org; Mon, 08 Feb 2016 04:30:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSi8w-000139-NZ for qemu-devel@nongnu.org; Mon, 08 Feb 2016 04:30:06 -0500 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:32850) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSi8w-000131-Gq for qemu-devel@nongnu.org; Mon, 08 Feb 2016 04:30:02 -0500 Received: by mail-wm0-x22d.google.com with SMTP id g62so124138033wme.0 for ; Mon, 08 Feb 2016 01:30:02 -0800 (PST) Sender: Paolo Bonzini References: <1450284981-10641-1-git-send-email-apyrgio@arrikto.com> From: Paolo Bonzini Message-ID: <56B86013.1050504@redhat.com> Date: Mon, 8 Feb 2016 10:29:55 +0100 MIME-Version: 1.0 In-Reply-To: <1450284981-10641-1-git-send-email-apyrgio@arrikto.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH] os-posix: Log to logfile in case of daemonize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Pyrgiotis , qemu-devel@nongnu.org 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); > }