Annotation of src/usr.bin/at/panic.c, Revision 1.3
1.3 ! millert 1: /* $OpenBSD: panic.c,v 1.2 1996/06/26 05:31:28 deraadt Exp $ */
1.1 deraadt 2: /* $NetBSD: panic.c,v 1.2 1995/03/25 18:13:33 glass Exp $ */
3:
4: /*
5: * panic.c - terminate fast in case of error
6: * Copyright (c) 1993 by Thomas Koenig
7: * All rights reserved.
8: *
9: * Redistribution and use in source and binary forms, with or without
10: * modification, are permitted provided that the following conditions
11: * are met:
12: * 1. Redistributions of source code must retain the above copyright
13: * notice, this list of conditions and the following disclaimer.
14: * 2. The name of the author(s) may not be used to endorse or promote
15: * products derived from this software without specific prior written
16: * permission.
17: *
18: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
19: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25: * THEORY OF LIABILITY, WETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28: */
29:
30: /* System Headers */
31:
32: #include <errno.h>
33: #include <stdio.h>
34: #include <stdlib.h>
35: #include <unistd.h>
36:
37: /* Local headers */
38:
39: #include "panic.h"
40: #include "at.h"
1.3 ! millert 41: #include "privs.h"
1.1 deraadt 42:
43: /* File scope variables */
44:
45: #ifndef lint
1.3 ! millert 46: static char rcsid[] = "$OpenBSD: panic.c,v 1.2 1996/06/26 05:31:28 deraadt Exp $";
1.1 deraadt 47: #endif
48:
49: /* External variables */
50:
51: /* Global functions */
52:
53: void
54: panic(a)
55: char *a;
56: {
57: /* Something fatal has happened, print error message and exit.
58: */
59: fprintf(stderr, "%s: %s\n", namep, a);
1.3 ! millert 60: if (fcreated) {
! 61: PRIV_START
1.1 deraadt 62: unlink(atfile);
1.3 ! millert 63: PRIV_END
! 64: }
1.1 deraadt 65:
66: exit(EXIT_FAILURE);
67: }
68:
69: void
70: perr(a)
71: char *a;
72: {
73: /* Some operating system error; print error message and exit.
74: */
75: perror(a);
1.3 ! millert 76: if (fcreated) {
! 77: PRIV_START
1.1 deraadt 78: unlink(atfile);
1.3 ! millert 79: PRIV_END
! 80: }
1.1 deraadt 81:
82: exit(EXIT_FAILURE);
83: }
84:
85: void
86: perr2(a, b)
87: char *a, *b;
88: {
89: fprintf(stderr, "%s", a);
90: perr(b);
91: }
92:
93: void
94: usage(void)
95: {
96: /* Print usage and exit.
97: */
98: fprintf(stderr, "Usage: at [-q x] [-f file] [-m] time\n"
99: " atq [-q x] [-v]\n"
100: " atrm [-q x] job ...\n"
101: " batch [-f file] [-m]\n");
102: exit(EXIT_FAILURE);
103: }