From: Kevin Wolf Subject: [PATCH 4/6] tapdisk-ioemu: Write messages to a logfile Date: Fri, 13 Mar 2009 10:16:41 +0100 Message-ID: <1236935803-32548-5-git-send-email-kwolf@suse.de> References: <1236935803-32548-1-git-send-email-kwolf@suse.de> Return-path: In-Reply-To: <1236935803-32548-1-git-send-email-kwolf@suse.de> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: Ian.Jackson@eu.citrix.com, Kevin Wolf List-Id: xen-devel@lists.xenproject.org Typically, tapdisk-ioemu runs as a daemon and messages to stderr are simply lost. Write them to a logfile instead. Signed-off-by: Kevin Wolf --- tapdisk-ioemu.c | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tapdisk-ioemu.c b/tapdisk-ioemu.c index 5e5ccc2..31f7f59 100644 --- a/tapdisk-ioemu.c +++ b/tapdisk-ioemu.c @@ -86,15 +86,22 @@ int main(void) struct timeval tv; void *old_fd_start = NULL; - logfile = stderr; - + /* Daemonize */ + if (fork() != 0) + exit(0); + bdrv_init(); init_blktap(); - /* Daemonize */ - if (fork() != 0) - exit(0); - + logfile = fopen("/var/log/xen/tapdisk-ioemu.log", "a"); + if (logfile) { + setbuf(logfile, NULL); + fclose(stderr); + stderr = logfile; + } else { + logfile = stderr; + } + /* * Main loop: Pass events to the corrsponding handlers and check for * completed aio operations. -- 1.6.0.2