X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Fri, 5 Sep 2008 00:05:41 +0100 From: Alex Smith To: cygwin AT cygwin DOT com Subject: PATCH: Re: cygutils/cygstart - wait till task terminates - also pass on exit status Message-ID: <20080904230541.GA10174@router.inet> Reply-To: madalexonline AT yahoo DOT co DOT uk References: <40q0a4d1qej604aerns94mr6562dr5tigg AT 4ax DOT com> <48A0AF77 DOT 30709 AT mscha DOT org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="M9NhX3UHpAaciwkO" Content-Disposition: inline In-Reply-To: <48A0AF77.30709@mscha.org> X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com --M9NhX3UHpAaciwkO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline The recent patch sumbitted by Barry Kelly to add an option to cygstart to have it wait for the process to terminate is most useful. However it would be more useful still if it were to return the exit status of the process in this case. The attached patch implements this small addition and should be applied on top of Barry Kelly's. - Alex --M9NhX3UHpAaciwkO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="cygstart-1.3.2-1.aws-wait-return.patch" diff -r -u -p src/cygstart/cygstart.c newsrc/cygstart/cygstart.c --- src/cygstart/cygstart.c 2008-09-04 22:49:41.000000000 +0100 +++ newsrc/cygstart/cygstart.c 2008-09-04 23:04:52.000000000 +0100 @@ -410,7 +410,7 @@ if (file) free(file); - return (ret ? 0 : 1); + return ret; } /* Start a program, or open a file or URL, using Cygwin POSIX paths */ @@ -454,10 +454,10 @@ int ret = (int) ShellExecute(NULL, action, aPath, args, workDir, show); if (ret >= 32) { - return TRUE; + return 0; } else { fprintf(stderr, "Unable to start '%s': %s\n", aPath, startError(ret)); - return FALSE; + return 1; } } else { SHELLEXECUTEINFO sei; @@ -474,21 +474,26 @@ if (!ShellExecuteEx(&sei)) { if (((int) sei.hInstApp) < 32) { fprintf(stderr, "Unable to start '%s': %s\n", aPath, startError((int) sei.hInstApp)); - return FALSE; + return 1; } else { fprintf(stderr, "Unable to start '%s': ", aPath); printLastError(stderr); fprintf(stderr, "\n"); - return FALSE; + return 1; } } if (sei.hProcess) { + DWORD code; WaitForSingleObject(sei.hProcess, INFINITE); + if (!GetExitCodeProcess(sei.hProcess, &code)) { + code = 1; + } CloseHandle(sei.hProcess); + return (int) code; } - return TRUE; + return 0; } } --M9NhX3UHpAaciwkO Content-Type: text/plain; charset=us-ascii -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ --M9NhX3UHpAaciwkO--