Add wrappers for ExitProcess, TerminateProcess

Charles Wilson cygwin@cwilson.fastmail.fm
Mon Oct 5 23:27:00 GMT 2009


Christopher Faylor wrote:
> I've checked in the sigExeced part of this patch.  Thanks.

The checkin does not yet appear to have taken effect, because
  $ cvs update && cvs diff
still shows the sigExeced stuff -- so, it's still in the patch/changelog
below.

> For the other part, if you're willing, I think you should just do what
> Corinna suggested.

Attached. The implementation of terminate_process and exit_process may
be somewhat paranoid, but I really don't want to let anybody
accidentally kill the wrong process, or clobber their own exit value
when terminating some other process.


Tested with:
==============================================
#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_TERMINATE_PROCESS,
                   GetCurrentProcess(),
                   STATUS_ILLEGAL_DLL_RELOCATION);
//  cygwin_internal (CW_EXIT_PROCESS, STATUS_ILLEGAL_DLL_RELOCATION);
  exit (1);
}
==============================================


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

	Add cygwin wrappers for ExitProcess and TerminateProcess.
	* include/sys/cygwin.h: Declare new cygwin_getinfo_types
	CW_TERMINATE_PROCESS and CW_EXIT_PROCESS.
	* external.cc (terminate_process): New function.
	(exit_process): New function.
	(cygwin_internal): Handle CW_TERMINATE_PROCESS and
	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.

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


More information about the Cygwin-patches mailing list