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