You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by iv...@apache.org on 2023/01/21 13:54:24 UTC
svn commit: r1906863 - in /apr/apr/trunk: CHANGES threadproc/win32/proc.c
Author: ivan
Date: Sat Jan 21 13:54:24 2023
New Revision: 1906863
URL: http://svn.apache.org/viewvc?rev=1906863&view=rev
Log:
apr_proc_create(): Fix incorrect error handling when pipes are redirected
on Windows.
* threadproc/win32/proc.c
(apr_proc_create): Save last error immediately after CreateProcessAsUserW()/
CreateProcessW() call, otherwise it can be lost by later calls.
Modified:
apr/apr/trunk/CHANGES
apr/apr/trunk/threadproc/win32/proc.c
Modified: apr/apr/trunk/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/trunk/CHANGES?rev=1906863&r1=1906862&r2=1906863&view=diff
==============================================================================
--- apr/apr/trunk/CHANGES [utf-8] (original)
+++ apr/apr/trunk/CHANGES [utf-8] Sat Jan 21 13:54:24 2023
@@ -268,6 +268,9 @@ Changes for APR 2.0.0
*) apr_thread_create: Fix potential race condition on Windows. [Ivan Zhakov]
+ *) apr_proc_create(): Fix incorrect error handling when pipes are redirected
+ on Windows [Ivan Zhakov]
+
Changes for APR and APR-util 1.7.x and later:
*) http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/CHANGES?view=markup
Modified: apr/apr/trunk/threadproc/win32/proc.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/threadproc/win32/proc.c?rev=1906863&r1=1906862&r2=1906863&view=diff
==============================================================================
--- apr/apr/trunk/threadproc/win32/proc.c (original)
+++ apr/apr/trunk/threadproc/win32/proc.c Sat Jan 21 13:54:24 2023
@@ -865,7 +865,7 @@ APR_DECLARE(apr_status_t) apr_proc_creat
LeaveCriticalSection(&proc_lock);
return rv;
}
- rv = CreateProcessAsUserW(attr->user_token,
+ if (!CreateProcessAsUserW(attr->user_token,
wprg, wcmd,
attr->sa,
NULL,
@@ -873,18 +873,30 @@ APR_DECLARE(apr_status_t) apr_proc_creat
dwCreationFlags,
pEnvBlock,
wcwd,
- &si, &pi);
+ &si, &pi)) {
+ /* Save error code. */
+ rv = apr_get_os_error();
+ }
+ else {
+ rv = APR_SUCCESS;
+ }
RevertToSelf();
}
else {
- rv = CreateProcessW(wprg, wcmd, /* Executable & Command line */
+ if (!CreateProcessW(wprg, wcmd, /* Executable & Command line */
NULL, NULL, /* Proc & thread security attributes */
TRUE, /* Inherit handles */
dwCreationFlags, /* Creation flags */
pEnvBlock, /* Environment block */
wcwd, /* Current directory name */
- &si, &pi);
+ &si, &pi)) {
+ /* Save error code. */
+ rv = apr_get_os_error();
+ }
+ else {
+ rv = APR_SUCCESS;
+ }
}
if ((attr->child_in && attr->child_in->filehand)
@@ -912,8 +924,9 @@ APR_DECLARE(apr_status_t) apr_proc_creat
/* Check CreateProcess result
*/
- if (!rv)
- return apr_get_os_error();
+ if (rv) {
+ return rv;
+ }
/* XXX Orphaned handle warning - no fix due to broken apr_proc_t api.
*/