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 60ed080 stdout and stderr need to be open in shared mode 60ed080 is described below commit 60ed080ebfe0bee5c61a5ab4bc4a2f7d696f3ce6 Author: Mark Thomas <ma...@apache.org> AuthorDate: Mon Sep 30 15:43:16 2019 +0100 stdout and stderr need to be open in shared mode --- src/native/windows/apps/prunsrv/prunsrv.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/native/windows/apps/prunsrv/prunsrv.c b/src/native/windows/apps/prunsrv/prunsrv.c index 5cb816a..47abbe4 100644 --- a/src/native/windows/apps/prunsrv/prunsrv.c +++ b/src/native/windows/apps/prunsrv/prunsrv.c @@ -32,6 +32,7 @@ #include <stddef.h> #include <fcntl.h> #include <io.h> /* _open_osfhandle */ +#include <share.h> #ifndef MIN #define MIN(a,b) (((a)<(b)) ? (a) : (b)) @@ -321,16 +322,16 @@ static BOOL redirectStdStreams(APX_STDWRAP *lpWrapper, LPAPXCMDLINE lpCmdline) */ if (!aOut) DeleteFileW(lpWrapper->szStdOutFilename); - if ((_wfopen_s(&lpWrapper->fpStdOutFile, - lpWrapper->szStdOutFilename, - L"a"))) { - lpWrapper->szStdOutFilename = NULL; - } - else { + if ((lpWrapper->fpStdOutFile = _wfsopen(lpWrapper->szStdOutFilename, + L"a", + _SH_DENYNO))) { _dup2(_fileno(lpWrapper->fpStdOutFile), 1); *stdout = *lpWrapper->fpStdOutFile; setvbuf(stdout, NULL, _IONBF, 0); } + else { + lpWrapper->szStdOutFilename = NULL; + } } if (lpWrapper->szStdErrFilename) { if (lstrcmpiW(lpWrapper->szStdErrFilename, PRSRV_AUTO) == 0) { @@ -347,16 +348,16 @@ static BOOL redirectStdStreams(APX_STDWRAP *lpWrapper, LPAPXCMDLINE lpCmdline) } if (!aErr) DeleteFileW(lpWrapper->szStdErrFilename); - if ((_wfopen_s(&lpWrapper->fpStdErrFile, - lpWrapper->szStdErrFilename, - L"a"))) { - lpWrapper->szStdOutFilename = NULL; - } - else { + if ((lpWrapper->fpStdErrFile = _wfsopen(lpWrapper->szStdErrFilename, + L"a", + _SH_DENYNO))) { _dup2(_fileno(lpWrapper->fpStdErrFile), 2); *stderr = *lpWrapper->fpStdErrFile; setvbuf(stderr, NULL, _IONBF, 0); } + else { + lpWrapper->szStdOutFilename = NULL; + } } else if (lpWrapper->fpStdOutFile) { _dup2(_fileno(lpWrapper->fpStdOutFile), 2);