signal.inc 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. Const { For sending a signal }
  13. SA_NOCLDSTOP = 8;
  14. SA_ONSTACK = $001; { take signal on signal stack }
  15. SA_RESTART = $002; { restart system call on signal return }
  16. SA_RESETHAND = $004; { reset to SIG_DFL when taking signal }
  17. SA_NODEFER = $010; { don't mask the signal we're delivering }
  18. SA_NOCLDWAIT = $020; { don't keep zombies around }
  19. SA_SIGINFO = $040; { signal handler with SA_SIGINFO args }
  20. SA_USERTRAMP = $100; { SUNOS compat: Do not bounce off kernel's sigtramp }
  21. SIG_BLOCK = 1;
  22. SIG_UNBLOCK = 2;
  23. SIG_SETMASK = 3;
  24. {BSD Checked}
  25. SIG_DFL = 0 ;
  26. SIG_IGN = 1 ;
  27. SIG_ERR = -1 ;
  28. SIGHUP = 1;
  29. SIGINT = 2;
  30. SIGQUIT = 3;
  31. SIGILL = 4;
  32. SIGTRAP = 5;
  33. SIGABRT = 6;
  34. SIGIOT = 6;
  35. SIGEMT = 7;
  36. SIGFPE = 8;
  37. SIGKILL = 9;
  38. SIGBUS = 10;
  39. SIGSEGV = 11;
  40. SIGSYS = 12;
  41. SIGPIPE = 13;
  42. SIGALRM = 14;
  43. SIGTERM = 15;
  44. SIGURG = 16;
  45. SIGSTOP = 17;
  46. SIGTSTP = 18;
  47. SIGCONT = 19;
  48. SIGCHLD = 20;
  49. SIGTTIN = 21;
  50. SIGTTOU = 22;
  51. SIGIO = 23;
  52. SIGXCPU = 24;
  53. SIGXFSZ = 25;
  54. SIGVTALRM = 26;
  55. SIGPROF = 27;
  56. SIGWINCH = 28;
  57. SIGINFO = 29;
  58. SIGUSR1 = 30;
  59. SIGUSR2 = 31;
  60. {$packrecords C}
  61. const
  62. SI_PAD_SIZE = ((128/sizeof(longint)) - 3);
  63. {
  64. * The sequence of the fields/registers in struct sigcontext should match
  65. * those in mcontext_t.
  66. }
  67. type sigset_t = array[0..3] of cardinal;
  68. PSigContextRec = ^SigContextRec;
  69. SigContextRec = record
  70. sc_mask : sigset_t; { signal mask to restore }
  71. sc_onstack : longint; { sigstack state to restore }
  72. sc_gs : longint; { machine state (struct trapframe): }
  73. sc_fs : longint;
  74. sc_es : longint;
  75. sc_ds : longint;
  76. sc_edi : longint;
  77. sc_esi : longint;
  78. sc_ebp : longint;
  79. sc_isp : longint;
  80. sc_ebx : longint;
  81. sc_edx : longint;
  82. sc_ecx : longint;
  83. sc_eax : longint;
  84. sc_trapno : longint;
  85. sc_err : longint;
  86. sc_eip : longint;
  87. sc_cs : longint;
  88. sc_efl : longint;
  89. sc_esp : longint;
  90. sc_ss : longint;
  91. {
  92. * XXX FPU state is 27 * 4 bytes h/w, 1 * 4 bytes s/w (probably not
  93. * needed here), or that + 16 * 4 bytes for emulators (probably all
  94. * needed here). The "spare" bytes are mostly not spare.
  95. }
  96. en_cw : cardinal; { control word (16bits used) }
  97. en_sw : cardinal; { status word (16bits) }
  98. en_tw : cardinal; { tag word (16bits) }
  99. en_fip : cardinal; { floating point instruction pointer }
  100. en_fcs : word; { floating code segment selector }
  101. en_opcode : word; { opcode last executed (11 bits ) }
  102. en_foo : cardinal; { floating operand offset }
  103. en_fos : cardinal; { floating operand segment selector }
  104. fpr_acc : array[0..79] of char;
  105. fpr_ex_sw : cardinal;
  106. fpr_pad : array[0..63] of char;
  107. end;
  108. SignalHandler = Procedure(Sig : Longint);cdecl;
  109. PSignalHandler = ^SignalHandler;
  110. SignalRestorer = Procedure;cdecl;
  111. PSignalRestorer = ^SignalRestorer;
  112. {$ifdef powerpc}
  113. TSigaction= procedure(Sig: Longint); cdecl;
  114. {$else}
  115. {$define BSDHandler}
  116. {$ifdef BSDHandler}
  117. TSigAction = procedure(Sig: Longint; code:longint;var SigContext: SigContextRec);cdecl;
  118. {$else}
  119. TSigAction = procedure(Sig: Longint; var sininfo:tsiginfo_t;var SigContext: SigContextRec);cdecl;
  120. {$endif}
  121. {$endif}
  122. Sigset=sigset_t;
  123. TSigset=sigset_t;
  124. PSigSet = ^SigSet;
  125. SigActionRec = packed record
  126. // Handler : record
  127. sa_handler : TSigAction;
  128. // case byte of
  129. // 0: (Sh: SignalHandler);
  130. // 1: (Sa: TSigAction);
  131. // end;
  132. Sa_Flags : Longint;
  133. Sa_Mask : SigSet;
  134. end;
  135. PSigActionRec = ^SigActionRec;
  136. {
  137. Change action of process upon receipt of a signal.
  138. Signum specifies the signal (all except SigKill and SigStop).
  139. If Act is non-nil, it is used to specify the new action.
  140. If OldAct is non-nil the previous action is saved there.
  141. }
  142. {
  143. $Log$
  144. Revision 1.4 2004-01-04 15:55:47 marco
  145. * additions
  146. Revision 1.3 2004/01/04 01:11:28 marco
  147. * a new qod port of the freebsd rtl. To be refined in the coming days.
  148. Revision 1.2 2003/01/21 15:39:45 marco
  149. * NetBSD first rtl. Still not 100%, but close
  150. Revision 1.1.2.1 2001/08/10 11:07:17 pierre
  151. New NetBSD files taken and adapted from FreeBSD
  152. Revision 1.1.2.1 2000/09/16 11:19:08 marco
  153. * Moved files from BSD to FreeBSD directory, with some small changes
  154. Revision 1.1.2.1 2000/09/10 16:18:41 marco
  155. initial version
  156. Revision 1.2 2000/03/31 23:11:23 pierre
  157. * TSigAction Context param is the full record not a pointer
  158. Revision 1.1 2000/03/31 13:24:28 jonas
  159. * signal handling using sigaction when compiled with -dnewsignal
  160. (allows multiple signals to be received in one run)
  161. }