incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: Exit code 3 on MSVC and ICC/Windows
Date Thu, 10 Apr 2008 19:08:53 GMT
Farid Zaripov wrote:
>   Below is a listing of the raise() function from MSVC CRT:

abort() has the same effect as exit(3) on Windows? What a mess!

Maybe we should ditch abort() and use TerminateProcess() instead,
with some unique value to let us distinguish our own SIGABRT from
exit(3).

Martin

> int __cdecl raise (
>         int signum
>         )
> {
> [...]
>         /*
> 
>         * If the current action is SIG_IGN, just return
> 
>         */
> 
>         if ( sigact == SIG_IGN )
> 
>                 return(0);
> 
>  
> 
>         /*
> 
>         * If the current action is SIG_DFL, take the default action
> 
>         */
> 
>         if ( sigact == SIG_DFL ) {
> 
>                 /*
> 
>                 * The current default action for all of the supported
> 
>                 * signals is to terminate with an exit code of 3.
> 
>                 */
> 
>                 _exit(3);
> 
>         }
> 
> [...]
> }
>  
>   And also the listing of the abort() :
>  
> void __cdecl abort (
> 
>         void
> 
>         )
> 
> {
> 
>         _PHNDLR sigabrt_act = SIG_DFL;
> 
>         if (__abort_behavior & _WRITE_ABORT_MSG)
> 
>         {
> 
>             /* write the abort message */
> 
>             _NMSG_WRITE(_RT_ABORT);
> 
>         }
> 
>  
> 
>         /* Check if the user installed a handler for SIGABRT.
> 
>         * We need to read the user handler atomically in the case
> 
>         * another thread is aborting while we change the signal
> 
>         * handler.
> 
>         */
> 
>         sigabrt_act = __get_sigabrt();
> 
>         if (sigabrt_act != SIG_DFL)
> 
>         {
> 
>             raise(SIGABRT);
> 
>         }
> 
>  
> 
>         /* If there is no user handler for SIGABRT or if the user
> 
>         * handler returns, then exit from the program anyway
> 
>         */
> 
> [...]
> 
>         /* If we don't want to call ReportFault, then we call _exit(3), which is the
> 
>         * same as invoking the default handler for SIGABRT
> 
>         */
> 
>  
> 
>         _exit(3);
> 
> }
> 
> Farid.
>  


Mime
View raw message