<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:blue'>void</span><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:#010001'>HandleAndPrintSignal</span>()<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'>{<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:#010001'>printf</span>(<span style='color:#A31515'>"I am in the segfault signal handler AND I WILL HANDLE YOUR SIG!!!!\n"</span>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:blue'>while</span>(1){ <span style='color:#010001'>printf</span>(<span style='color:#A31515'>"LALALA\n"</span>); }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:#010001'>exit</span>(1);<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>}<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:blue'>void</span><span style='font-size:10.0pt;font-family:"Courier New"'> *<span style='color:#010001'>POSIX_Init</span>(<span style='color:blue'>void</span> *<span style='color:#010001'>args</span>)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>{<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:#010001'>printf</span>(<span style='color:#A31515'>"BENS BIG NOTE: Initializing Signal Handler\n"</span>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:blue'>struct</span> <span style='color:#010001'>sigaction</span> <span style='color:#010001'>sa</span>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:#010001'>sa</span>.<span style='color:#010001'>sa_handler</span> = <span style='color:#010001'>HandleAndPrintSignal</span>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:#010001'>sigemptyset</span>(&<span style='color:#010001'>sa</span>.<span style='color:#010001'>sa_mask</span>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:#010001'>sa</span>.<span style='color:#010001'>sa_flags</span> = <span style='color:#010001'>SA_SIGINFO</span>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:blue'>if</span> (<span style='color:#010001'>sigaction</span> (<span style='color:#010001'>SIGSEGV</span>, &<span style='color:#010001'>sa</span>, 0)) {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:#010001'>printf</span>(<span style='color:#A31515'>"A ERROR OCCURED WITH THIS!"</span>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:#010001'>exit</span>(1);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:blue'>int</span> *<span style='color:#010001'>p</span> = <span style='color:#010001'>NULL</span>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:blue'>while</span>(1)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:#010001'>printf</span>(<span style='color:#A31515'>"Doing some looping\n"</span>);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> *(<span style='color:#010001'>p</span>--) = 5;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:#010001'>printf</span>(<span style='color:#A31515'>"%d"</span>, *<span style='color:#010001'>p</span>);<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'> }<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>}<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'>This will cause a seg fault as expected. However instead of being caught by the signal handler a kernel routine under vectors_init.c will print the following stack trace:<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:#558ED5'>Exception handler called for exception 12 (0xC)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:#558ED5'> Next PC or Address of fault = 003506BC<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:#558ED5'> Saved MSR = 00003012<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:#558ED5'> Context: Task ID 0x0B010001<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:#558ED5'> R0 = 003506B8 R1 = 06827C58 R2 = 004A54F8 R3 = 00000000<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:#558ED5'> R4 = 06827BE8 R5 = 00000013 R6 = 06827C84 R7 = 00000001<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:#558ED5'> R8 = 00000000 R9 = 00000800 R10 = F0002000 R11 = F0002000<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:#558ED5'> R12 = 25555582 R13 = 0051A7C0 R14 = 55555555 R15 = 55555555<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:#558ED5'> R16 = 55555555 R17 = 55555555 R18 = 55555555 R19 = 55555555<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:#558ED5'> R20 = 55555555 R21 = 55555555 R22 = 06827F10 R23 = 00000001<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:#558ED5'> R24 = 06827D78 R25 = 003CD20C R26 = 06827D94 R27 = 00000000<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:#558ED5'> R28 = 006FF698 R29 = 00000013 R30 = 00000000 R31 = 1A01000E<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:#558ED5'> CR = 45555582<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:#558ED5'> CTR = 00350EB0<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:#558ED5'> XER = 00000000<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:#558ED5'> LR = 003506B8<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:#558ED5'> DAR = 00000000<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:#558ED5'>Stack Trace:<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:#558ED5'> IP: 0x003506BC, LR: 0x003506B8<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:#558ED5'>--^ 0x0038C364--^ 0x00389AF0--^ 0x0036BC5C--^ 0x00350F70--^ 0x0038AD78<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:#558ED5'>--^ 0x0036071C--^ 0x0036D330--^ 0x0036D3B0--^ 0x0033E514--^ 0x003399D0<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:#558ED5'>--^ 0x0033B4F0--^ 0x0033D80C--^ 0x0019B68C--^ 0x003C6934--^ 0x003C6850<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:#558ED5'>Suspending faulting task (0x0B010001)<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Is there something special that needs to be done to set up signal handlers for RTEMS? It seems like from this manual: <o:p></o:p></p><p class=MsoNormal><a href="http://docs.rtems.org/doc-current/share/rtems/pdf/posix1003_1.pdf%20under%20section%203.3.1.1">http://docs.rtems.org/doc-current/share/rtems/pdf/posix1003_1.pdf </a> <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>under section 3.3.1.1 indicates that signals have been implemented. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Is there something that I am doing wrong?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>