summaryrefslogtreecommitdiff
path: root/rtl/solaris/signal.inc
blob: e69e621cd5e64867455741f4b96cbedadd86473a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
{
    This file is part of the Free Pascal run time library.
    Copyright (c) 2001 by Free Pascal development team

    This file implements all the types/constants related
    to signal for Solaris.

    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 **********************************************************************}

const
  {************************ signals *****************************}
  { more can be provided. Herein are only included the required  }
  { values.                                                      }
  {**************************************************************}
  SIGABRT    =  6;     { abnormal termination           }
  SIGALRM    = 14;     { alarm clock (used with alarm() }
  SIGFPE     =  8;     { illegal arithmetic operation   }
  SIGHUP     =  1;     { Hangup                         }
  SIGILL     =  4;     { Illegal instruction            }
  SIGINT     =  2;     { Interactive attention signal   }
  SIGKILL    =  9;     { Kill, cannot be caught         }
  SIGPIPE    = 13;     { Broken pipe signal             }
  SIGQUIT    =  3;     { Interactive termination signal }
  SIGSEGV    = 11;     { Detection of invalid memory reference }
  SIGTERM    = 15;     { Termination request           }
  SIGUSR1    = 16;     { Application defined signal 1  }
  SIGUSR2    = 17;     { Application defined signal 2  }
  SIGCHLD    = 18;     { Child process terminated / stopped }
  SIGCONT    = 25;     { Continue if stopped               }
  SIGSTOP    = 23;     { Stop signal. cannot be cuaght     }
  SIGSTP     = 24;     { Interactive stop signal           }
  SIGTTIN    = 26;     { Background read from TTY          }
  SIGTTOU    = 27;     { Background write to TTY           }
  SIGBUS     = 10;     { Access to undefined memory        }

  { Solaris specific signals                               }

  SIGTRAP    =  5;      { trace trap (not reset when caught) }
  SIGIOT     =  6;      { IOT instruction }
  SIGEMT     =  7;      { EMT instruction }
  SIGSYS     = 12;      { bad argument to system call }
  SIGCLD     = 18;      { child status change }
  SIGPWR     = 19;      { power-fail restart }
  SIGWINCH   = 20;      { window size change }
  SIGURG     = 21;      { urgent socket condition }
  SIGPOLL    = 22;      { pollable event occurred }
  SIGIO      = SIGPOLL;{ socket I/O possible (SIGPOLL alias) }
  SIGVTALRM  = 28;      { virtual timer expired }
  SIGPROF    = 29;      { profiling timer expired }
  SIGXCPU    = 30;      { exceeded cpu limit }
  SIGXFSZ    = 31;      { exceeded file size limit }
  SIGWAITING = 32;      { process's lwps are blocked }
  SIGLWP     = 33;      { special signal used by thread library }
  SIGFREEZE  = 34;      { special signal used by CPR }
  SIGTHAW    = 35;      { special signal used by CPR }
  SIGCANCEL  = 36;      { thread cancellation signal used by libthread }
  SIGLOST    = 37;      { resource lost (eg, record-lock lost) }

  SIG_BLOCK   = 1;
  SIG_UNBLOCK = 2;
  SIG_SETMASK = 3;

  SIG_DFL = 0 ;
  SIG_IGN = 1 ;
  SIG_ERR = -1 ;

  { definitions for the sa_flags field }
  SA_ONSTACK   = $00000001;
  SA_RESETHAND = $00000002;
  SA_RESTART   = $00000004;
  SA_SIGINFO   = $00000008;
  SA_NODEFER   = $00000010;
  SA_NOCLDWAIT = $00010000;
  SA_WAITSIG   = $00010000;

{$ifdef cpu64}
  SI_PAD_SIZE   = ((256 div sizeof(cint)) - 4);
{$else}
  SI_PAD_SIZE   = ((128 div sizeof(cint)) - 3);
{$endif}

type
  SigSet  =  array[0..wordsinsigset-1] of cint;
  sigset_t= SigSet;
  PSigSet = ^SigSet;
  psigset_t=psigset;
  TSigSet = SigSet;

  t_pdata = record
    case longint of
      1 : ( _kill : record
              _uid   : uid_t;
              _value : cint; { signal sent? }
            end );
      2 : ( _cld : record
              _utime  : clock_t;
              _status : cint;
              _stime  : clock_t;
            end );
  end;

  t_proc = record
    _pid: pid_t;
    _pdata: t_pdata;
  end;

  psiginfo = ^tsiginfo;
  tsiginfo = record
       si_signo : cint;
       si_code  : cint;
       si_errno : cint;
{$ifdef cpu64}
       si_pad   : cint;
{$endif cpu64}
       _sifields : record
           case longint of
              0 : ( _pad : array[0..(SI_PAD_SIZE)-1] of cint );
              1 : ( _proc : t_proc);
              3 : ( _rctl : record
                   _entity : longint; { int32_t }
                end );
              5 : ( _sigfault : record
                   _addr : pointer;
                   _trapno : cint;
                   _pc    : pointer;
                end );
              6 : ( _sigpoll : record
                   _fd : longint;
                   _band : longint;
                end );
           end;
    end;

{ CPU dependent TSigContext }
{$i sighndh.inc}

type
  SignalHandler   = Procedure(Sig : Longint);cdecl;
  PSignalHandler  = ^SignalHandler;
  SignalRestorer  = Procedure;cdecl;
  PSignalRestorer = ^SignalRestorer;
  SigActionHandler = procedure(sig : longint; SigInfo: PSigInfo; SigContext: PSigContext);cdecl;

{$ifdef x86_64}
  SigActionRec = record  // this needs correct 8-byte alignment for hander
    Sa_Flags    : cuint;
    sa_handler  : SigActionHandler;
    Sa_Mask     : SigSet;
  end;
{$else not x86_64}
  SigActionRec = packed record  // this is temporary for the migration
    Sa_Flags    : cuint;
    sa_handler  : SigActionHandler;
    Sa_Mask     : SigSet;
    sa_resv : array[1..2] of cint;  { for non-_LP64 platforms only                       }
  end;
{$endif not x86_64}
  TSigActionRec = SigActionRec;
  PSigActionRec = ^SigActionRec;