File: sigaction.2.html

package info (click to toggle)
rtlinux 3.1pre3-2
  • links: PTS
  • area: non-free
  • in suites: sarge, woody
  • size: 4,892 kB
  • ctags: 4,228
  • sloc: ansic: 26,204; sh: 2,069; makefile: 1,414; perl: 855; tcl: 489; asm: 380; cpp: 42
file content (487 lines) | stat: -rw-r--r-- 8,888 bytes parent folder | download | duplicates (2)
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
<HTML
><HEAD
><TITLE
>sigaction</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
"></HEAD
><BODY
CLASS="REFENTRY"
><H1
><A
NAME="AEN1"
>sigaction</A
></H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN5"
></A
><H2
>Name</H2
>sigaction&nbsp;--&nbsp;RTLinux POSIX signal handling functions</DIV
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN8"
></A
><H2
>Synopsis</H2
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="SYNOPSIS"
>       #include &#60;posix/signal.h&#62;

       int <TT
CLASS="FUNCTION"
>sigaction</TT
>(int <TT
CLASS="PARAMETER"
><I
>signum</I
></TT
>, const struct sigaction *<TT
CLASS="PARAMETER"
><I
>act</I
></TT
>, struct sigaction *<TT
CLASS="PARAMETER"
><I
>oldact</I
></TT
>);

	int  <TT
CLASS="FUNCTION"
>sigprocmask</TT
>(int  <TT
CLASS="PARAMETER"
><I
>how</I
></TT
>,  const  sigset_t *<TT
CLASS="PARAMETER"
><I
>set</I
></TT
>, sigset_t *<TT
CLASS="PARAMETER"
><I
>oldset</I
></TT
>);</PRE
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN18"
></A
><H2
>DESCRIPTION</H2
><P
>Signals interactions with pthreads is one of the less well defined and most
contentious parts of POSIX. Many problems come from the interaction between
process signals and thread signals. RTLinux V3.0 uses the concept of
process signals to provide an interface to hard interrupt handlers. The
signals RTL_SIGIRQMIN  to  RTL_SIGIRQMIN + NR_IRQS refer to global hardware
interrupts, and installing signal handlers is the same as installing interrupt
handlers.</P
><P
>RTLinux provides the POSIX <TT
CLASS="FUNCTION"
>sigaction</TT
> function to install handlers for hardware interrupts and also to provide POSIX signaling (this is
incomplete in V3.0). </P
><P
><TT
CLASS="PARAMETER"
><I
>signum</I
></TT
> specifies the signal and can be any valid signal except <TT
CLASS="LITERAL"
>SIGKILL</TT
> and <TT
CLASS="LITERAL"
>SIGSTOP</TT
>.</P
><P
>If <TT
CLASS="PARAMETER"
><I
>act</I
></TT
> is non-null, the new action for signal <TT
CLASS="PARAMETER"
><I
>signum</I
></TT
> is installed from <TT
CLASS="PARAMETER"
><I
>act</I
></TT
>.  If <TT
CLASS="PARAMETER"
><I
>oldact</I
></TT
> is non-null, the previous action is saved in <TT
CLASS="PARAMETER"
><I
>oldact</I
></TT
>.</P
><P
>The <TT
CLASS="LITERAL"
>sigaction</TT
> structure is defined as
<TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>       struct sigaction{
           void (*sa_handler)(int);
           sigset_t sa_mask;
           int sa_flags;
           void (*sa_restorer)(void);
           unsigned int sa_focus;
       }</PRE
></TD
></TR
></TABLE
>
The <TT
CLASS="PARAMETER"
><I
>sa_focus</I
></TT
> field is an RTLinux-specific extension that
is a bit map defining which processors on an SMP system can accept these
interrupts. This is machine-specific and may only be used for hardware 
interrupts using the RTL_SIGIRQMIN+n, to catch hardware interrupt n.</P
><P
><TT
CLASS="PARAMETER"
><I
>sa_handler</I
></TT
> specifies the action to be associated with signum and may be <TT
CLASS="LITERAL"
>SIG_DFL</TT
> for the default action, <TT
CLASS="LITERAL"
>SIG_IGN</TT
> to ignore this signal, or a pointer to a signal handling function.</P
><P
><TT
CLASS="PARAMETER"
><I
>sa_mask</I
></TT
>  gives  a  mask of signals which should be blocked during execution of the signal handler.  In addition,  the signal which triggered the handler will be blocked, unless the <TT
CLASS="LITERAL"
>SA_NODEFER</TT
> or <TT
CLASS="LITERAL"
>SA_NOMASK</TT
> flags are used. In V3 and prior RTLinux
these flags have no effect. Furthermore, when a signal handler for a hard
interrupt is entered all interrupts are blocked by default.</P
><P
><TT
CLASS="PARAMETER"
><I
>sa_flags</I
></TT
> specifies a set of flags which modify the behaviour of the signal handling process.  In RTLinux V3.0 and earlier these
flags are ignored.</P
><P
>The <TT
CLASS="PARAMETER"
><I
>sa_focus</I
></TT
>
element is used to direct a hardware
interrupt to a particular set of processors in an <SPAN
CLASS="ACRONYM"
>SMP</SPAN
>
system. 
This element has no effiect on soft-interrupts, on processor-specific
interrupts (e.g. local timers and <SPAN
CLASS="ACRONYM"
>IPI</SPAN
>s), on uni-processor systems, or where the interrupt control logic does not support interrupt focus.</P
><P
>The <TT
CLASS="FUNCTION"
>sigprocmask</TT
> call is used to change the list of
currently blocked signals in a single threaded process. 
POSIX states that the sigprocmask call has undefined operation
in a multi-threaded process. 
In RTLinux, if the pthreads-based scheduling module
(<TT
CLASS="FUNCTION"
>rtl_sched</TT
>) is loaded or otherwise activated,
the RT process is multithreaded and sigprocmask behavior undefined, unless the <SPAN
CLASS="QUOTE"
>"how"</SPAN
> variable is set to <TT
CLASS="LITERAL"
>SIG_DISABLE</TT
> or <TT
CLASS="LITERAL"
>SIG_ENABLE</TT
>.  These two flags are RTLinux extensions.  The behaviour of the call is dependent on the value of how, as follows.</P
><P
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="LITERAL"
>SIG_BLOCK</TT
></DT
><DD
><P
>The set of blocked signals is the union of the current set and the set argument.</P
></DD
><DT
><TT
CLASS="LITERAL"
>SIG_UNBLOCK</TT
></DT
><DD
><P
>The signals in set are removed from the current set of blocked signals.  It is legal to attempt to unblock a  signal  which  is  not blocked.</P
></DD
><DT
><TT
CLASS="LITERAL"
>SIG_SETMASK</TT
></DT
><DD
><P
>The  set  of  blocked  signals is set to the argument set.</P
></DD
><DT
><TT
CLASS="LITERAL"
>SIG_DISABLE</TT
></DT
><DD
><P
>Turns on local processor interrupts.</P
></DD
><DT
><TT
CLASS="LITERAL"
>SIG_ENABLE</TT
></DT
><DD
><P
>Turns on local processor interrupts.</P
></DD
></DL
></DIV
></P
><P
>Note that in RTLinux, as in POSIX,  not all signals can be masked or blocked.</P
><P
>If <TT
CLASS="PARAMETER"
><I
>oldset</I
></TT
> is non-null, the previous value  of  the  signal mask is stored in <TT
CLASS="PARAMETER"
><I
>oldset</I
></TT
>.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN88"
></A
><H2
>RETURN VALUES</H2
><P
><TT
CLASS="FUNCTION"
>sigaction</TT
>, <TT
CLASS="FUNCTION"
>sigprocmask</TT
>, <TT
CLASS="FUNCTION"
>sigpending</TT
> and <TT
CLASS="FUNCTION"
>sigsuspend</TT
> return 0 on success and -1 on error.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN95"
></A
><H2
>ERRORS</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>EINVAL</DT
><DD
><P
>An invalid signal was specified.  This will also be generated  if  an  attempt  is  made  to change the action for <TT
CLASS="LITERAL"
>SIGKILL</TT
> or  <TT
CLASS="LITERAL"
>SIGSTOP</TT
>,  which  cannot  be caught.</P
></DD
><DT
>EFAULT</DT
><DD
><P
><TT
CLASS="PARAMETER"
><I
>act</I
></TT
>,<TT
CLASS="PARAMETER"
><I
>oldact</I
></TT
>, <TT
CLASS="PARAMETER"
><I
>set</I
></TT
> or <TT
CLASS="PARAMETER"
><I
>oldset</I
></TT
> point to memory which is not a valid part of the process address space.</P
></DD
><DT
>EINTR</DT
><DD
><P
>System call was interrupted. This cannot happen in RTLinux V3.0 or prior.</P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN116"
></A
><H2
>NOTES</H2
><P
>It is not possible to block <TT
CLASS="LITERAL"
>SIGKILL</TT
> or  <TT
CLASS="LITERAL"
>SIGSTOP</TT
>  with  the <TT
CLASS="FUNCTION"
>sigprocmask</TT
>  call.   Attempts  to  do  so will be silently ignored. RTLinux also adds an additional set of unmaskable and uncatchable signals.</P
><P
>According to POSIX, the behaviour of a  process  is  undefined after it ignores a <TT
CLASS="LITERAL"
>SIGFP</TT
>E, <TT
CLASS="LITERAL"
>SIGILL</TT
>, or <TT
CLASS="LITERAL"
>SIGSEGV</TT
> signal that was not generated by the <TT
CLASS="FUNCTION"
>kill()</TT
> or the <TT
CLASS="FUNCTION"
>raise()</TT
>  functions.  Integer division by zero has undefined result.  On some architectures  it  will  generate  a <TT
CLASS="LITERAL"
>SIGFPE</TT
>  signal.  (Also, dividing the most negative integer by -1 may generate <TT
CLASS="LITERAL"
>SIGFPE</TT
>.)  Ignoring this signal might lead to  an  endless loop.</P
><P
><TT
CLASS="LITERAL"
>SIGCHLD</TT
> cannot happen in V3.0 RTLinux or prior, since there
is no way to create child processes.</P
><P
>The POSIX spec only defines SA_NOCLDSTOP.   Use  of  other <TT
CLASS="PARAMETER"
><I
>sa_flags</I
></TT
> is non-portable.</P
><P
><TT
CLASS="FUNCTION"
>sigaction</TT
> can be called with a  null  second  argument  to query  the  current signal handler. It can also be used to check whether a given signal  is  valid  for  the  current machine, by  calling it  with null second and third arguments.</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN136"
></A
><H2
>SEE ALSO</H2
><A
HREF="../susv2/xsh/sigaction.html"
TARGET="_top"
>UNIX spec sigaction</A
>, <A
HREF="../susv2/xsh/kill.html"
TARGET="_top"
>UNIX spec kill(2)</A
><P
>2001 FSMLabs Inc.</P
><P
>All rights reserved.</P
></DIV
></BODY
></HTML
>