tbs0105.pp 826 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. {$ifdef go32v2}
  2. {$define OK}
  3. {$endif}
  4. {$ifdef linux}
  5. {$define OK}
  6. {$endif}
  7. { Win32 signal support is still missing ! }
  8. {$ifdef OK}
  9. {$ifdef go32v2}
  10. uses dpmiexcp;
  11. {$endif go32v2}
  12. {$ifdef linux}
  13. uses linux;
  14. {$endif linux}
  15. function our_sig(l : longint) : longint;{$ifdef linux}cdecl;{$endif}
  16. begin
  17. { If we land here the program works correctly !! }
  18. Writeln('Sigsegv signal recieved');
  19. our_sig:=0;
  20. Halt(0);
  21. end;
  22. Var
  23. Sel: Word;
  24. v: pointer;
  25. {$endif OK}
  26. Begin
  27. {$ifdef OK}
  28. Signal(SIGSEGV,signalhandler(@our_sig));
  29. { generate a sigsegv by writing to null-address }
  30. sel:=0;
  31. v:=nil;
  32. {$ifdef go32v2}
  33. { on win9X no zero page protection :( }
  34. v:=pointer(-2);
  35. {$endif go32v2}
  36. word(v^):=sel;
  37. { we should not go to here }
  38. Writeln('Error : signal not called');
  39. Halt(1);
  40. {$endif OK}
  41. end.