forgot a newline in the last change (to psym)
[unix-history] / usr / src / old / sh / error.c
CommitLineData
9def2197
KM
1/* error.c 4.1 82/05/07 */
2
3#
4/*
5 * UNIX shell
6 *
7 * S. R. Bourne
8 * Bell Telephone Laboratories
9 *
10 */
11
12#include "defs.h"
13
14
15/* ======== error handling ======== */
16
17exitset()
18{
19 assnum(&exitadr,exitval);
20}
21
22sigchk()
23{
24 /* Find out if it is time to go away.
25 * `trapnote' is set to SIGSET when fault is seen and
26 * no trap has been set.
27 */
28 IF trapnote&SIGSET
29 THEN exitsh(SIGFAIL);
30 FI
31}
32
33failed(s1,s2)
34 STRING s1, s2;
35{
36 prp(); prs(s1);
37 IF s2
38 THEN prs(colon); prs(s2);
39 FI
40 newline(); exitsh(ERROR);
41}
42
43error(s)
44 STRING s;
45{
46 failed(s,NIL);
47}
48
49exitsh(xno)
50 INT xno;
51{
52 /* Arrive here from `FATAL' errors
53 * a) exit command,
54 * b) default trap,
55 * c) fault with no trap set.
56 *
57 * Action is to return to command level or exit.
58 */
59 exitval=xno;
60 IF (flags & (forked|errflg|ttyflg)) != ttyflg
61 THEN done();
62 ELSE clearup();
63 longjmp(errshell,1);
64 FI
65}
66
67done()
68{
69 REG STRING t;
70 IF t=trapcom[0]
71 THEN trapcom[0]=0; /*should free but not long */
72 execexp(t,0);
73 FI
74 rmtemp(0);
75 exit(exitval);
76}
77
78rmtemp(base)
79 IOPTR base;
80{
81 WHILE iotemp>base
82 DO unlink(iotemp->ioname);
83 iotemp=iotemp->iolst;
84 OD
85}