annotate docs/ccguide/intercept.refentry @ 1914:395e22e5c0bd

Added more defs for porting back to level 1 someday
author boisy
date Sun, 20 Nov 2005 17:11:16 +0000
parents 0fa5d3280b5e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
466
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
1 <refentry id="intercept">
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
2 <refnamediv>
468
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
3 <refname>Intercept</refname>
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
4 <refpurpose>set function for interrupt processing</refpurpose>
466
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
5 </refnamediv>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
6
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
7 <refsynopsisdiv>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
8 <funcsynopsis>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
9 <funcprototype>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
10 <funcdef><function>intercept</function></funcdef>
570
253b6096ee01 All function prototypes are added.
roug
parents: 542
diff changeset
11 <paramdef>int <parameter>(* func)</parameter>
253b6096ee01 All function prototypes are added.
roug
parents: 542
diff changeset
12 <funcparams>int</funcparams></paramdef>
466
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
13 </funcprototype>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
14 </funcsynopsis>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
15
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
16 </refsynopsisdiv>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
17
542
73319ee6a57e All "See Also" implemented
roug
parents: 468
diff changeset
18 <refsect1><title>Assembler Equivalent</title>
73319ee6a57e All "See Also" implemented
roug
parents: 468
diff changeset
19 <para>
73319ee6a57e All "See Also" implemented
roug
parents: 468
diff changeset
20 os9 F$ICPT
73319ee6a57e All "See Also" implemented
roug
parents: 468
diff changeset
21 </para>
73319ee6a57e All "See Also" implemented
roug
parents: 468
diff changeset
22 </refsect1>
73319ee6a57e All "See Also" implemented
roug
parents: 468
diff changeset
23
466
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
24 <refsect1><title>Description</title>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
25 <para>
600
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
26 Intercept instructs OS-9 to pass control to the function "func"
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
27 when an interrupt (signal) is received by the current process.
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
28 </para>
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
29 <para>
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
30 If the interrupt processing function has an argument, it will
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
31 contain the value of the signal received. On return from
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
32 "func", the process resumes at the point in the program where
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
33 it was interrupted by the signal. "Interrupt()" is an
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
34 alternative to the use of "signal()" to process interrupts.
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
35 </para>
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
36 <para>
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
37 As an example, suppose we wish to ensure that a partially
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
38 completed output file is deleted if an interrupt is received.
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
39 The body of the program might include:
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
40 <programlisting>
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
41 char *temp_file = "temp"; /* name of temporary file */
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
42 int pn=0; /* path number */
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
43 int intrupt(); /* predeclaration */
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
44
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
45 ...
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
46
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
47 intercept(intrupt); /* route interrupt processing */
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
48 pn = creat(temp_file,3); /* make a new file */
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
49
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
50 ...
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
51
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
52 write(pn,string,count); /* write string to temp file */
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
53
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
54 ...
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
55
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
56 close(pn);
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
57 pn=0;
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
58
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
59 ...
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
60 </programlisting>
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
61 The interrupt routine might be coded:
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
62 <programlisting>
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
63 intrupt(sig);
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
64 {
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
65 if (pn){ /* only done if pn refers to an open file */
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
66 close(pn);
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
67 unlink(temp_file); /* delete */
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
68 }
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
69 exit(sig);
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
70 }
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
71 </programlisting>
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
72 </para>
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
73 </refsect1>
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
74
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
75 <refsect1><title>Caveats</title>
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
76 <para>
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
77 "Intercept()" and "signal()" are mutually incompatible so that
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
78 calls to both must not appear in the same program. The linker
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
79 guards against this by giving an "entry name clash - _sigint"
0fa5d3280b5e All refentries finished.
roug
parents: 570
diff changeset
80 error if it is attempted.
466
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
81 </para>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
82 </refsect1>
542
73319ee6a57e All "See Also" implemented
roug
parents: 468
diff changeset
83
73319ee6a57e All "See Also" implemented
roug
parents: 468
diff changeset
84 <refsect1><title>See Also</title>
73319ee6a57e All "See Also" implemented
roug
parents: 468
diff changeset
85 <para>
73319ee6a57e All "See Also" implemented
roug
parents: 468
diff changeset
86 <link linkend="signal">signal()</link>
73319ee6a57e All "See Also" implemented
roug
parents: 468
diff changeset
87 </para>
73319ee6a57e All "See Also" implemented
roug
parents: 468
diff changeset
88 </refsect1>
73319ee6a57e All "See Also" implemented
roug
parents: 468
diff changeset
89
466
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
90 </refentry>