You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2020/11/13 11:56:56 UTC
[commons-daemon] branch master updated: Fix DAEMON-424 - Ensure
stdout/stderr msgs are not lost at startup
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-daemon.git
The following commit(s) were added to refs/heads/master by this push:
new 37d3232 Fix DAEMON-424 - Ensure stdout/stderr msgs are not lost at startup
37d3232 is described below
commit 37d3232374b39a52447995fa0073ce0137a11148
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Nov 13 11:56:38 2020 +0000
Fix DAEMON-424 - Ensure stdout/stderr msgs are not lost at startup
Patch provided by Bernhard Scholz
---
src/changes/changes.xml | 4 ++++
src/native/windows/src/javajni.c | 8 ++++++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c8eb5dc..31c5afa 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -39,6 +39,10 @@
</properties>
<body>
<release version="1.2.4" date="TBD" description="Bug fix release">
+ <action issue="DAEMON-424" type="fix" dev="markt" due-to="Bernhard Scholz">
+ Procrun. Ensure that log messages written to stdout and stderr are not
+ lost during start-up.
+ </action>
<action issue="DAEMON-425" type="fix" dev="markt">
Procrun. Correct a regression introduced in 1.2.3. Enable the service to
start if the Options value is not present in the registry.
diff --git a/src/native/windows/src/javajni.c b/src/native/windows/src/javajni.c
index 4da3e5e..1ca3345 100644
--- a/src/native/windows/src/javajni.c
+++ b/src/native/windows/src/javajni.c
@@ -1039,14 +1039,18 @@ static DWORD WINAPI __apxJavaWorkerThread(LPVOID lpParameter)
apxLogWrite(APXLOG_MARK_DEBUG "DLL search path set to '%S'",
pArgs->szLibraryPath);
}
+
+ /* System.out/System.err streams must be replaced before loading the main class. */
+ /* Otherwise both old and new streams may be used by the Java application, corrupting the log file. */
+ apxJavaSetOut(pArgs->hJava, TRUE, pArgs->szStdErrFilename);
+ apxJavaSetOut(pArgs->hJava, FALSE, pArgs->szStdOutFilename);
+
if (!apxJavaLoadMainClass(pArgs->hJava,
pArgs->szClassName,
pArgs->szMethodName,
pArgs->lpArguments)) {
WORKER_EXIT(3);
}
- apxJavaSetOut(pArgs->hJava, TRUE, pArgs->szStdErrFilename);
- apxJavaSetOut(pArgs->hJava, FALSE, pArgs->szStdOutFilename);
/* Check if we have a class and a method */
if (!lpJava->clWorker.jClazz || !lpJava->clWorker.jMethod) {