Add wrappers for ExitProcess, TerminateProcess

Charles Wilson cygwin@cwilson.fastmail.fm
Tue Oct 6 21:58:00 GMT 2009


Christopher Faylor wrote:
> On Tue, Oct 06, 2009 at 05:19:03PM -0400, Charles Wilson wrote:
>> Do I need to increment the minor version when adding a new
>> cygwin_internal call?  It seems so:
> 
> Yes.  Thanks for catching that.

As committed (and tested):

2009-10-05  Charles Wilson  <cygwin@cwilson.fastmail.fm>

	Add cygwin wrapper for ExitProcess and TerminateProcess.
	* include/sys/cygwin.h: Declare new cygwin_getinfo_type
	CW_EXIT_PROCESS.
	* external.cc (exit_process): New function.
	(cygwin_internal): Handle CW_EXIT_PROCESS.
	* pinfo.h (pinfo::set_exit_code): New method.
	* pinfo.cc (pinfo::set_exit_code): New, refactored from...
	(pinfo::maybe_set_exit_code_from_windows): here. Call it.
	* include/cygwin/version.h: Bump CYGWIN_VERSION_API_MINOR
	to 215 to reflect the above change.


Test proggie:
========================================================
#include <stdio.h>
#include <windows.h>
#include <ntdef.h>
#include <sys/cygwin.h>

#define STATUS_ILLEGAL_DLL_RELOCATION ((NTSTATUS) 0xc0000269)
#define STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION ((NTSTATUS) 0xe0000269)
#define STATUS_DLL_NOT_FOUND          ((NTSTATUS) 0xc0000135)

int main(int argc, char* argv[])
{
  cygwin_internal (CW_EXIT_PROCESS,
                   STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION,
                   1);
//                   0);
  exit (1);
}
========================================================

Note that neither cygwin nor ExitProcess/TerminateProcess care that they
have no idea what the '0xe0000269' status code means -- for this test I
stripped out all of the new pseudo-reloc support code from my repo.
However, cygwin just says: "this value is > 0xc00000000, and I don't
have a special case to handle it, so default: exit_code = 127;"

Which is what we want, for now.

$ gcc -o foo.exe foo.c
$ ./foo.exe
$ echo $?
127

P.S. Thanks for all the reviews, folks!  Public interface changes should
always be subject to "strict scrutiny", even more so than purely
internal implementation details, so this was good...

--
Chuck
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 01-cygwin-terminate-process.patch-final
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20091006/0cf8a9a5/attachment.ksh>


More information about the Cygwin-patches mailing list