[m-rev.] for review: Handle exit codes of forked processes on windows safely.

Paul Bone paul at bone.id.au
Fri Feb 20 11:25:39 AEDT 2015


On Thu, Feb 19, 2015 at 11:03:23AM +1100, Julien Fischer wrote:
>
> Hi Paul,
>
> On Wed, 18 Feb 2015, Paul Bone wrote:
>
>> Branches: version-14_01-branch, master
>>
>> For review by anyone
>>
>> ---
>>
>> Handle exit codes of forked processes on windows safely.
>>
>> MSVC doesn't provide the WIFEXITED and other macros that help a programmer
>> determine if a child process exited with an error message or was killed by a
>> signal.
>
> Windows doesn't really have a notion of signals per se.  The C and C++
> libraries on Windows provide "signals" as far as they are required to by
> the standards for those languages, but underneath they're not the same
> as they are on Unix.
> (A little light reading for those interested:
> https://technet.microsoft.com/en-us/library/bb496995.aspx>

Cheers, that looks very useful.

>> In these cases Mercury assumes that positive numbers are exit codes
>> and negative numbers mean that a process was killed by a signal.
>>
>> When "cl" exited with errors, returning the error code -2, mmc --make
>> thought that it was killed by a signal and failed to display the compilation
>> errors.
>>
>> This patch removes the existing code that tries to detect signals when these
>> macros are not available.  As far as I know platforms like windows don't
>> have a concept of SysV signals, therefore signals can only occur when using
>> cygwin or some other compatibility layer which will then provide the
>> WIFEXITED and other macros.
>>
>> I considered using the windows API directly however it didn't (as far as I
>> could find) provide any concept of signals, so I rejected this idea.
>
> Search for "Structured Exception Handling".
>

Cheers

I've made the changes.  Thanks.

-- 
Paul Bone



More information about the reviews mailing list