signal.inc 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by Jonas Maebe,
  4. member of the Free Pascal development team.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. Const { For sending a signal }
  12. SA_NOCLDSTOP = 8;
  13. SA_ONSTACK = $001; { take signal on signal stack }
  14. SA_RESTART = $002; { restart system call on signal return }
  15. SA_RESETHAND = $004; { reset to SIG_DFL when taking signal }
  16. SA_NODEFER = $010; { don't mask the signal we're delivering }
  17. SA_NOCLDWAIT = $020; { don't keep zombies around }
  18. SA_SIGINFO = $040; { signal handler with SA_SIGINFO args }
  19. SIG_BLOCK = 1;
  20. SIG_UNBLOCK = 2;
  21. SIG_SETMASK = 3;
  22. {BSD Checked}
  23. SIG_DFL = 0 ;
  24. SIG_IGN = 1 ;
  25. SIG_ERR = -1 ;
  26. SIGHUP = 1;
  27. SIGINT = 2;
  28. SIGQUIT = 3;
  29. SIGILL = 4;
  30. SIGTRAP = 5;
  31. SIGABRT = 6;
  32. SIGIOT = 6;
  33. SIGEMT = 7;
  34. SIGFPE = 8;
  35. SIGKILL = 9;
  36. SIGBUS = 10;
  37. SIGSEGV = 11;
  38. SIGSYS = 12;
  39. SIGPIPE = 13;
  40. SIGALRM = 14;
  41. SIGTERM = 15;
  42. SIGURG = 16;
  43. SIGSTOP = 17;
  44. SIGTSTP = 18;
  45. SIGCONT = 19;
  46. SIGCHLD = 20;
  47. SIGTTIN = 21;
  48. SIGTTOU = 22;
  49. SIGIO = 23;
  50. SIGXCPU = 24;
  51. SIGXFSZ = 25;
  52. SIGVTALRM = 26;
  53. SIGPROF = 27;
  54. SIGWINCH = 28;
  55. SIGINFO = 29;
  56. SIGUSR1 = 30;
  57. SIGUSR2 = 31;
  58. {$packrecords C}
  59. const
  60. SI_PAD_SIZE = ((128/sizeof(longint)) - 3);
  61. {
  62. * The sequence of the fields/registers in struct sigcontext should match
  63. * those in mcontext_t.
  64. }
  65. type sigset_t = array[0..3] of Longint;
  66. psigcontext = ^sigcontextrec;
  67. PSigContextRec = ^SigContextRec;
  68. SigContextRec = record
  69. sc_mask : sigset_t; { signal mask to restore }
  70. sc_onstack : cint64; { sigstack state to restore }
  71. sc_rdi : cint64; { machine state (struct trapframe): }
  72. sc_rsi : cint64;
  73. sc_rdx : cint64;
  74. sc_rcx : cint64;
  75. sc_r8 : cint64;
  76. sc_r9 : cint64;
  77. sc_rax : cint64;
  78. sc_rbx : cint64;
  79. sc_rbp : cint64;
  80. sc_r10 : cint64;
  81. sc_r11 : cint64;
  82. sc_r12 : cint64;
  83. sc_r13 : cint64;
  84. sc_r14 : cint64;
  85. sc_r15 : cint64;
  86. sc_xflags : cint64;
  87. sc_trapno : cint64;
  88. sc_addr : cint64;
  89. sc_flags : cint64;
  90. sc_err : cint64;
  91. sc_rip : cint64;
  92. sc_cs : cint64;
  93. sc_rflags : cint64;
  94. sc_rsp : cint64;
  95. sc_ss : cint64;
  96. sc_len : cuint32;
  97. sc_fpformat : cuint32;
  98. sc_ownedfp : cuint32;
  99. sc_reserved : cuint32;
  100. sc_unused : array[0..7] of cuint32;
  101. sc_pregs : array[0..255] of cuint32;
  102. end;
  103. Sigval = Record
  104. Case Boolean OF
  105. { Members as suggested by Annex C of POSIX 1003.1b. }
  106. false : (sigval_int : Longint);
  107. True : (sigval_ptr : Pointer);
  108. End;
  109. PSigInfo = ^SigInfo_t;
  110. PSigInfo_t = ^SigInfo_t;
  111. SigInfo_t = record
  112. si_signo, { signal number }
  113. si_errno, { errno association }
  114. {
  115. * Cause of signal, one of the SI_ macros or signal-specific
  116. * values, i.e. one of the FPE_... values for SIGFPE. This
  117. * value is equivalent to the second argument to an old-style
  118. * FreeBSD signal handler.
  119. }
  120. si_code, { signal code }
  121. si_pid : cint32; { sending process }
  122. si_uid : cuint32; { sender's ruid }
  123. si_status : cint32; { exit value }
  124. si_addr : Pointer; { faulting instruction }
  125. si_value : SigVal; { signal value }
  126. si_band : cint32; { band event for SIGPOLL }
  127. __spare : array[0..6] of cint32; { gimme some slack }
  128. end;
  129. TSigInfo = SigInfo_t;
  130. TSigInfo_t = TSigInfo;
  131. SignalHandler = Procedure(Sig : Longint);cdecl;
  132. TSignalHandler = Procedure(Sig : Longint);cdecl;
  133. PSignalHandler = ^SignalHandler;
  134. SignalRestorer = Procedure;cdecl;
  135. PSignalRestorer = ^SignalRestorer;
  136. sigActionHandler = procedure(Sig: Longint; sininfo:psiginfo; SigContext: PSigContext);cdecl;
  137. TSigset=sigset_t;
  138. sigset=tsigset;
  139. PSigSet = ^TSigSet;
  140. SigActionRec = packed record
  141. { Handler : record
  142. case byte of
  143. 0: (Sh: SignalHandler);
  144. 1: (Sa: TSigAction);
  145. end;}
  146. sa_handler : sigActionHandler;
  147. Sa_Flags : Longint;
  148. Sa_Mask : TSigSet;
  149. end;
  150. PSigActionRec = ^SigActionRec;
  151. pstack_t = ^stack_t;
  152. stack_t = record
  153. ss_sp : pChar; {* signal stack base *}
  154. ss_size : size_t; {* signal stack length *}
  155. ss_flags: cint32; {* SS_DISABLE and/or SS_ONSTACK *}
  156. end;
  157. TStack = stack_t;
  158. PStack = pstack_t;
  159. {
  160. Change action of process upon receipt of a signal.
  161. Signum specifies the signal (all except SigKill and SigStop).
  162. If Act is non-nil, it is used to specify the new action.
  163. If OldAct is non-nil the previous action is saved there.
  164. }
  165. const
  166. FPE_INTOVF =1; { integer overflow }
  167. FPE_INTDIV =2; { integer divide by zero }
  168. FPE_FLTDIV =3; { floating point divide by zero }
  169. FPE_FLTOVF =4; { floating point overflow }
  170. FPE_FLTUND =5; { floating point underflow }
  171. FPE_FLTRES =6; { floating point inexact result }
  172. FPE_FLTINV =7; { invalid floating point operation }
  173. FPE_FLTSUB =8; { subscript out of range }