From: David Sommerseth Date: Mon, 13 Dec 2010 12:56:16 +0100 Message-Id: <1292241376-18056-1-git-send-email-davids@...1347...> In-Reply-To: References: Subject: [Openvpn-devel] [PATCH] Open log files as text files on Windows List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit To: openvpn-devel@lists.sourceforge.net Cc: David Sommerseth By giving the "t" flag to _fdopen() on Windows, the file will be opened in a "translate mode", where it will take care of converting \n to \r\n, and also look for the CTRL-Z mark when opening the log file in append mode. Reference: Thanks to Alon Bar-Lev for pointing out this solution. Reported-by: Thomas Reifferscheid Signed-off-by: David Sommerseth --- error.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/error.c b/error.c index 873718c..887f2d0 100644 --- a/error.c +++ b/error.c @@ -521,7 +521,7 @@ redirect_stdout_stderr (const char *file, bool append) /* open log_handle as FILE stream */ ASSERT (msgfp == NULL); - msgfp = _fdopen (log_fd, "w"); + msgfp = _fdopen (log_fd, "wt"); if (msgfp == NULL) msg (M_ERR, "Error: --log redirect failed due to _fdopen"); -- 1.7.2.3