signal.inc 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. {$packrecords C}
  12. {********************
  13. Signal
  14. ********************}
  15. Const
  16. { For sending a signal }
  17. {$ifdef SPARC}
  18. SA_SIGINFO = $200;
  19. SA_NOMASK = $20;
  20. SIG_BLOCK = 1;
  21. SIG_UNBLOCK = 2;
  22. SIG_SETMASK = 4;
  23. {$else SPARC}
  24. SA_NOCLDSTOP = 1;
  25. SA_NOCLDWAIT = 2;
  26. SA_SIGINFO = 4;
  27. SA_SHIRQ = $04000000;
  28. SA_STACK = $08000000;
  29. SA_RESTART = $10000000;
  30. SA_INTERRUPT = $20000000;
  31. SA_NOMASK = $40000000;
  32. SA_ONESHOT = $80000000;
  33. SIG_BLOCK = 0;
  34. SIG_UNBLOCK = 1;
  35. SIG_SETMASK = 2;
  36. {$endif SPARC}
  37. SIG_DFL = 0 ;
  38. SIG_IGN = 1 ;
  39. SIG_ERR = -1 ;
  40. {$ifdef cpusparc}
  41. SIGHUP = 1;
  42. SIGINT = 2;
  43. SIGQUIT = 3;
  44. SIGILL = 4;
  45. SIGTRAP = 5;
  46. SIGABRT = 6;
  47. SIGIOT = 6;
  48. SIGEMT = 7;
  49. SIGFPE = 8;
  50. SIGKILL = 9;
  51. SIGBUS = 10;
  52. SIGSEGV = 11;
  53. SIGSYS = 12;
  54. SIGPIPE = 13;
  55. SIGALRM = 14;
  56. SIGTERM = 15;
  57. SIGURG = 16;
  58. SIGSTOP = 17;
  59. SIGTSTP = 18;
  60. SIGCONT = 19;
  61. SIGCHLD = 20;
  62. SIGTTIN = 21;
  63. SIGTTOU = 22;
  64. SIGIO = 23;
  65. SIGPOLL = SIGIO;
  66. SIGXCPU = 24;
  67. SIGXFSZ = 25;
  68. SIGVTALRM = 26;
  69. SIGPROF = 27;
  70. SIGWINCH = 28;
  71. SIGLOST = 29;
  72. SIGPWR = SIGLOST;
  73. SIGUSR1 = 30;
  74. SIGUSR2 = 31;
  75. {$else cpusparc}
  76. SIGHUP = 1;
  77. SIGINT = 2;
  78. SIGQUIT = 3;
  79. SIGILL = 4;
  80. SIGTRAP = 5;
  81. SIGABRT = 6;
  82. SIGIOT = 6;
  83. SIGBUS = 7;
  84. SIGFPE = 8;
  85. SIGKILL = 9;
  86. SIGUSR1 = 10;
  87. SIGSEGV = 11;
  88. SIGUSR2 = 12;
  89. SIGPIPE = 13;
  90. SIGALRM = 14;
  91. SIGTerm = 15;
  92. SIGSTKFLT = 16;
  93. SIGCHLD = 17;
  94. SIGCONT = 18;
  95. SIGSTOP = 19;
  96. SIGTSTP = 20;
  97. SIGTTIN = 21;
  98. SIGTTOU = 22;
  99. SIGURG = 23;
  100. SIGXCPU = 24;
  101. SIGXFSZ = 25;
  102. SIGVTALRM = 26;
  103. SIGPROF = 27;
  104. SIGWINCH = 28;
  105. SIGIO = 29;
  106. SIGPOLL = SIGIO;
  107. SIGPWR = 30;
  108. SIGUNUSED = 31;
  109. {$endif cpusparc}
  110. const
  111. SI_PAD_SIZE = ((128 div sizeof(longint)) - 3);
  112. type
  113. SigSet = array[0..wordsinsigset-1] of cint;
  114. sigset_t= SigSet;
  115. PSigSet = ^SigSet;
  116. psigset_t=psigset;
  117. TSigSet = SigSet;
  118. psiginfo = ^tsiginfo;
  119. tsiginfo = record
  120. si_signo : longint;
  121. si_errno : longint;
  122. si_code : longint;
  123. _sifields : record
  124. case longint of
  125. 0 : ( _pad : array[0..(SI_PAD_SIZE)-1] of longint );
  126. 1 : ( _kill : record
  127. _pid : pid_t;
  128. _uid : uid_t;
  129. end );
  130. 2 : ( _timer : record
  131. _timer1 : dword;
  132. _timer2 : dword;
  133. end );
  134. 3 : ( _rt : record
  135. _pid : pid_t;
  136. _uid : uid_t;
  137. _sigval : pointer;
  138. end );
  139. 4 : ( _sigchld : record
  140. _pid : pid_t;
  141. _uid : uid_t;
  142. _status : longint;
  143. _utime : clock_t;
  144. _stime : clock_t;
  145. end );
  146. 5 : ( _sigfault : record
  147. _addr : pointer;
  148. end );
  149. 6 : ( _sigpoll : record
  150. _band : longint;
  151. _fd : longint;
  152. end );
  153. end;
  154. end;
  155. { CPU dependent TSigContext }
  156. {$i sighndh.inc}
  157. type
  158. SignalHandler = Procedure(Sig : Longint);cdecl;
  159. PSignalHandler = ^SignalHandler;
  160. SignalRestorer = Procedure;cdecl;
  161. PSignalRestorer = ^SignalRestorer;
  162. SigActionHandler = procedure(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext);cdecl;
  163. {$ifdef CPUARM}
  164. {$define NEWSIGNAL}
  165. {$endif CPUARM}
  166. {$ifdef CPUx86_64}
  167. {$define NEWSIGNAL}
  168. {$endif CPUx86_64}
  169. SigActionRec = packed record // this is temporary for the migration
  170. sa_handler : SigActionHandler;
  171. {$ifdef NEWSIGNAL}
  172. Sa_Flags : cuint;
  173. Sa_restorer : SignalRestorer; { Obsolete - Don't use }
  174. Sa_Mask : SigSet;
  175. {$else NEWSIGNAL}
  176. Sa_Mask : SigSet;
  177. Sa_Flags : Longint;
  178. Sa_restorer : SignalRestorer; { Obsolete - Don't use }
  179. {$endif NEWSIGNAL}
  180. end;
  181. TSigActionRec = SigActionRec;
  182. PSigActionRec = ^SigActionRec;