signal.inc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Jonas Maebe,
  5. member of the Free Pascal development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {$packrecords C}
  13. const
  14. SI_PAD_SIZE = ((128/sizeof(longint)) - 3);
  15. type
  16. tfpreg = record
  17. significand: array[0..3] of word;
  18. exponent: word;
  19. end;
  20. pfpstate = ^tfpstate;
  21. tfpstate = record
  22. cw, sw, tag, ipoff, cssel, dataoff, datasel: cardinal;
  23. st: array[0..7] of tfpreg;
  24. status: cardinal;
  25. end;
  26. PSigContextRec = ^SigContextRec;
  27. SigContextRec = record
  28. gs, __gsh: word;
  29. fs, __fsh: word;
  30. es, __esh: word;
  31. ds, __dsh: word;
  32. edi: cardinal;
  33. esi: cardinal;
  34. ebp: cardinal;
  35. esp: cardinal;
  36. ebx: cardinal;
  37. edx: cardinal;
  38. ecx: cardinal;
  39. eax: cardinal;
  40. trapno: cardinal;
  41. err: cardinal;
  42. eip: cardinal;
  43. cs, __csh: word;
  44. eflags: cardinal;
  45. esp_at_signal: cardinal;
  46. ss, __ssh: word;
  47. fpstate: pfpstate;
  48. oldmask: cardinal;
  49. cr2: cardinal;
  50. end;
  51. (*
  52. PSigInfoRec = ^SigInfoRec;
  53. SigInfoRec = record
  54. si_signo: longint;
  55. si_errno: longint;
  56. si_code: longint;
  57. case longint of
  58. 0:
  59. (pad: array[SI_PAD_SIZE] of longint);
  60. 1: { kill }
  61. ( kill: record
  62. pid: longint; { sender's pid }
  63. uid : longint; { sender's uid }
  64. end );
  65. 2: { POSIX.1b timers }
  66. ( timer : record
  67. timer1 : cardinal;
  68. timer2 : cardinal;
  69. end );
  70. 3: { POSIX.1b signals }
  71. ( rt : record
  72. pid : longint; { sender's pid }
  73. uid : longint; { sender's uid }
  74. sigval : longint;
  75. end );
  76. 4: { SIGCHLD }
  77. ( sigchld : record
  78. pid : longint; { which child }
  79. uid : longint; { sender's uid }
  80. status : longint; { exit code }
  81. utime : timeval;
  82. stime : timeval;
  83. end );
  84. 5: { SIGILL, SIGFPE, SIGSEGV, SIGBUS }
  85. ( sigfault : record
  86. addr : pointer;{ faulting insn/memory ref. }
  87. end );
  88. 6:
  89. ( sigpoll : record
  90. band : longint; { POLL_IN, POLL_OUT, POLL_MSG }
  91. fd : longint;
  92. end );
  93. end;
  94. *)
  95. SignalHandler = Procedure(Sig : Longint);cdecl;
  96. PSignalHandler = ^SignalHandler;
  97. SignalRestorer = Procedure;cdecl;
  98. PSignalRestorer = ^SignalRestorer;
  99. TSigAction = procedure(Sig: Longint; SigContext: SigContextRec);cdecl;
  100. SigSet = Longint;
  101. PSigSet = ^SigSet;
  102. SigActionRec = packed record
  103. Handler : record
  104. case byte of
  105. 0: (Sh: SignalHandler);
  106. 1: (Sa: TSigAction);
  107. end;
  108. Sa_Mask : SigSet;
  109. Sa_Flags : Longint;
  110. Sa_restorer : SignalRestorer; { Obsolete - Don't use }
  111. end;
  112. PSigActionRec = ^SigActionRec;
  113. Procedure SigAction(Signum:Integer;Act,OldAct:PSigActionRec );
  114. {
  115. Change action of process upon receipt of a signal.
  116. Signum specifies the signal (all except SigKill and SigStop).
  117. If Act is non-nil, it is used to specify the new action.
  118. If OldAct is non-nil the previous action is saved there.
  119. }
  120. Var
  121. sr : Syscallregs;
  122. begin
  123. sr.reg2:=Signum;
  124. sr.reg3:=Longint(act);
  125. sr.reg4:=Longint(oldact);
  126. SysCall(Syscall_nr_sigaction,sr);
  127. end;
  128. {
  129. $Log$
  130. Revision 1.4 2003-03-29 16:55:56 michael
  131. + Patch from Mattias Gaertner for single typeinfo
  132. Revision 1.3 2002/09/07 16:01:20 peter
  133. * old logs removed and tabs fixed
  134. }