[cmd] Wait for command to complete when spawned through cmd /c

Ann and Jason Edmeades jason at edmeades.me.uk
Thu Nov 29 17:26:16 CST 2012


cmd /c notepad should wait for notepad to complete before returning
whereas the code only waited for GUI apps to complete when they
were launched from a batch program (ie with a context).

[Fixes bug 19668]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20121129/d2f17801/attachment.html>
-------------- next part --------------
From f5f27c4a7672cf9b103607d272fe053d0e114836 Mon Sep 17 00:00:00 2001
From: Jason Edmeades <jason at edmeades.me.uk>
Date: Thu, 29 Nov 2012 23:23:25 +0000
Subject: [cmd] Wait for command to complete when spawned through cmd /c

cmd /c notepad should wait for notepad to complete before returning
whereas the code only waited for GUI apps to complete when they
were launched from a batch program (ie with a context).

[Fixes bug 19668]
---
 programs/cmd/wcmdmain.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index cb9fab6..e373d19 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -1201,8 +1201,10 @@ void WCMD_run_program (WCHAR *command, BOOL called)
         if (!assumeInternal && !console) errorlevel = 0;
         else
         {
-            /* Always wait when called in a batch program context */
-            if (assumeInternal || context || !HIWORD(console)) WaitForSingleObject (pe.hProcess, INFINITE);
+            /* Always wait when non-interactive (cmd /c or in batch program),
+               or for console applications                                    */
+            if (assumeInternal || !interactive || !HIWORD(console))
+              WaitForSingleObject (pe.hProcess, INFINITE);
             GetExitCodeProcess (pe.hProcess, &errorlevel);
             if (errorlevel == STILL_ACTIVE) errorlevel = 0;
         }
-- 
1.7.9.5


More information about the wine-patches mailing list