This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Add wrappers for ExitProcess, TerminateProcess


Christopher Faylor wrote:
> On Tue, Oct 06, 2009 at 02:45:22PM -0400, Charles Wilson wrote:
>> Christopher Faylor wrote:
>>
>>> Looks good with a minor kvetch: Could you use "bool" instead of "BOOL"
>>> for variables that don't have to be passed to a Windows function that
>>> takes a BOOL argument?
>> For the static function exit_process(), sure. But the argument list
>> accepted by cygwin_internal() should be C-compatible, shouldn't it? So,
>> how about the following?
> 
> "bool" is C-compatible.  You just have to #include <stdbool.h> .

I keep forgetting about stdbool.

> But now that you mention it, I wonder if we really should have to
> require an #include <windows.h> to use this.  Maybe it should just
> be unsigned long.

I don't see that /that/ makes much difference. Some of the existing
cygwin_internal calls already expect DWORD argument (sure, you could
pass them as unsigned long instead).  Or
CW_GET_POSIX_SECURITY_ATTRIBUTE, which expects a PSECURITY_ATTRIBUTES.

So, it's really a question of what do we want the user to have to
#include when they call, specifically, cygwin_internal(CW_EXIT_PROCESS,...).

Well, obviously, <sys/cygwin.h>.  They may or may not require <ntdef.h>
if they want to use pre-defined STATUS_* values.  But to me, the kicker
is: this is a wrapper/replacement for the w32 functions ExitProcess and
TerminateProcess. So...if someone *was* going to include <windows.h> in
order to call /those/ functions, I don't see why they'd object to doing
so to call the cygwin_internal(CW_EXIT_PROCESS,...) wrapper.

OTOH, this particular value is not even passed to those underlying w32
functions -- it's only used as part of the *cygwin* cygwin_internal
implementation.  Since we no longer pass a HANDLE to the
TerminateProcess wrapper, it does seem a bit icky to #include
<windows.h> only for a BOOL type that we don't even pass to the w32
functions.  Why should *cygwin* deliberately choose to use braindead w32
"types" when it doesn't need to?

...meh.

Having said all that, I really don't care one way or the other. We have
three possibilities:

1) current iteration (BOOL in cygwin_internal coerced to bool for static
function exit_process)
2) use bool throughout exceptions.cc, and expect caller to use C++ bool,
C99 bool, or stdbool.h bool.
3) use bool in static function exit_process, use unsigned long in
cygwin_internal and callers.

You guys pick one, and I'll do it that way.

--
Chuck


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]