public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* [PATCH setup] Propagate exit code of elevated process
@ 2018-07-07 12:41 Jon Turney
  2018-07-10 16:21 ` Ken Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Jon Turney @ 2018-07-07 12:41 UTC (permalink / raw)
  To: cygwin-apps; +Cc: Jon Turney

Propagate the exit code of elevated process, when --wait is used.

This addresses part of the problem about exit code noted in [1], although we
also need to audit that a non-zero exit code is reported in all error
situations.

[1] https://cygwin.com/ml/cygwin/2018-07/msg00020.html

Also report if starting the elevated child process failed.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
---
 main.cc | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/main.cc b/main.cc
index 9ca3f25..1374fb6 100644
--- a/main.cc
+++ b/main.cc
@@ -343,12 +343,16 @@ WinMain (HINSTANCE h,
 
 	if (ShellExecuteEx(&sei))
 	  {
+	    DWORD exitcode = 0;
 	    /* Wait until child process is finished. */
 	    if (WaitOption && sei.hProcess != NULL)
-	      WaitForSingleObject (sei.hProcess, INFINITE);
+	      if (!WaitForSingleObject (sei.hProcess, INFINITE))
+	        GetExitCodeProcess (sei.hProcess, &exitcode);
+	    Logger ().setExitMsg (IDS_ELEVATED);
+	    Logger ().exit (exitcode, false);
 	  }
-	Logger ().setExitMsg (IDS_ELEVATED);
-	Logger ().exit (0, false);
+	Log (LOG_PLAIN) << "Starting elevated child process failed" << endLog;
+	Logger ().exit (1, false);
       }
     else
       {
-- 
2.17.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH setup] Propagate exit code of elevated process
  2018-07-07 12:41 [PATCH setup] Propagate exit code of elevated process Jon Turney
@ 2018-07-10 16:21 ` Ken Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Ken Brown @ 2018-07-10 16:21 UTC (permalink / raw)
  To: cygwin-apps

On 7/7/2018 8:40 AM, Jon Turney wrote:
> Propagate the exit code of elevated process, when --wait is used.
> 
> This addresses part of the problem about exit code noted in [1], although we
> also need to audit that a non-zero exit code is reported in all error
> situations.

I haven't done a complete audit, but I did happen to spot one place that 
needs attention.  See the comment (made by you in 2010) in 
PostInstallResultsPage::OnUnattended().

Ken

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-10 16:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-07 12:41 [PATCH setup] Propagate exit code of elevated process Jon Turney
2018-07-10 16:21 ` Ken Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).