ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

signal.c
Go to the documentation of this file.
00001 #include <precomp.h>
00002 #include "include/internal/wine/msvcrt.h"
00003 
00004 static sig_element signal_list[] =
00005    {
00006       { SIGINT, "CTRL+C",SIG_DFL },
00007       { SIGILL, "Illegal instruction",SIG_DFL },
00008       { SIGFPE, "Floating-point exception",SIG_DFL },
00009       { SIGSEGV, "Illegal storage access",SIG_DFL },
00010       { SIGTERM, "Termination request",SIG_DFL },
00011       { SIGBREAK, "CTRL+BREAK",SIG_DFL },
00012       { SIGABRT, "Abnormal termination",SIG_DFL }
00013    };
00014 
00015 //int nsignal = 21;
00016 
00017 /*
00018  * @implemented
00019  */
00020 //void ( *signal( int sig, void (__cdecl *func) ( int sig [, int subcode ] )) ) ( int sig );
00021 
00022 
00023 __p_sig_fn_t signal(int sig, __p_sig_fn_t func)
00024 {
00025    __p_sig_fn_t temp;
00026    unsigned int i;
00027 
00028    switch (sig)
00029    {
00030       case SIGINT:
00031       case SIGILL:
00032       case SIGFPE:
00033       case SIGSEGV:
00034       case SIGTERM:
00035       case SIGBREAK:
00036       case SIGABRT:
00037          break;
00038 
00039       default:
00040          _set_errno(EINVAL);
00041          return SIG_ERR;
00042    }
00043 
00044    // check with IsBadCodePtr
00045    if ( (uintptr_t)func < 4096 && func != SIG_DFL && func != SIG_IGN)
00046    {
00047       _set_errno(EINVAL);
00048       return SIG_ERR;
00049    }
00050 
00051    for(i=0; i < sizeof(signal_list)/sizeof(signal_list[0]); i++)
00052    {
00053       if ( signal_list[i].signal == sig )
00054       {
00055          temp = signal_list[i].handler;
00056          signal_list[i].handler = func;
00057          return temp;
00058       }
00059    }
00060 
00061    /* should be impossible to get here */
00062    _set_errno(EINVAL);
00063    return SIG_ERR;
00064 }
00065 
00066 
00067 /*
00068  * @implemented
00069  */
00070 int
00071 raise(int sig)
00072 {
00073    __p_sig_fn_t temp = 0;
00074    unsigned int i;
00075 
00076    switch (sig)
00077    {
00078       case SIGINT:
00079       case SIGILL:
00080       case SIGFPE:
00081       case SIGSEGV:
00082       case SIGTERM:
00083       case SIGBREAK:
00084       case SIGABRT:
00085          break;
00086 
00087       default:
00088          //FIXME: set last err?
00089          return -1;
00090    }
00091 
00092 
00093    //  if(sig <= 0)
00094    //    return -1;
00095    //  if(sig > SIGMAX)
00096    //    return -1;
00097 
00098    for(i=0;i<sizeof(signal_list)/sizeof(signal_list[0]);i++)
00099    {
00100       if ( signal_list[i].signal == sig )
00101       {
00102          temp = signal_list[i].handler;
00103          break;
00104       }
00105    }
00106 
00107    if(temp == SIG_IGN)// || (sig == SIGQUIT && temp == (_p_sig_fn_t)SIG_DFL))
00108       return 0;   /* Ignore it */
00109 
00110    if(temp == SIG_DFL)
00111       _default_handler(sig); /* this does not return */
00112    else
00113       temp(sig);
00114 
00115    return 0;
00116 }
00117 
00118 
00119 
00120 void _default_handler(int sig)
00121 {
00122    _exit(3);
00123 }
00124 
00125 
00126 
00127 
00128 

Generated on Sun May 27 2012 04:36:36 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.