Add wrappers for ExitProcess, TerminateProcess

Charles Wilson cygwin@cwilson.fastmail.fm
Tue Oct 6 14:40:00 GMT 2009


Corinna Vinschen wrote:

> I can live with both variations, though I like the one entry point idea
> as in `cygwin_internal (CW_EXIT_PROCESS, UINT, bool)'  more.

As re-implemented, attached. (I used the windows BOOL type, rather than
the C99/C++ bool type).  Test case:


===================================
#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_RELOCATION,
                   TRUE);
//                   FALSE);
  exit (1);
}
===================================

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


2009-10-05  Charles Wilson  <...>

	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.
	* exceptions.cc: Move global variable sigExeced...
	* globals.cc: here.

OK?

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


More information about the Cygwin-patches mailing list