/*-1* panic.c - terminate fast in case of error2*3* SPDX-License-Identifier: BSD-2-Clause4*5* Copyright (C) 1993 Thomas Koenig6*7* Redistribution and use in source and binary forms, with or without8* modification, are permitted provided that the following conditions9* are met:10* 1. Redistributions of source code must retain the above copyright11* notice, this list of conditions and the following disclaimer.12* 2. The name of the author(s) may not be used to endorse or promote13* products derived from this software without specific prior written14* permission.15*16* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR17* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES18* 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, BUT21* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,22* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY23* THEORY OF LIABILITY, WETHER IN CONTRACT, STRICT LIABILITY, OR TORT24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF25* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.26*/2728#include <sys/cdefs.h>29/* System Headers */3031#include <err.h>32#include <errno.h>33#include <stdio.h>34#include <stdlib.h>35#include <unistd.h>3637/* Local headers */3839#include "panic.h"40#include "privs.h"41#include "at.h"4243/* External variables */4445/* Global functions */4647void48panic(const char *a)49{50/* Something fatal has happened, print error message and exit.51*/52if (fcreated) {53PRIV_START54unlink(atfile);55PRIV_END56}5758errx(EXIT_FAILURE, "%s", a);59}6061void62perr(const char *a)63{64/* Some operating system error; print error message and exit.65*/66int serrno = errno;6768if (fcreated) {69PRIV_START70unlink(atfile);71PRIV_END72}7374errno = serrno;75err(EXIT_FAILURE, "%s", a);76}7778void79usage(void)80{81/* Print usage and exit. */82fprintf(stderr, "usage: at [-q x] [-f file] [-m] time\n"83" at -c job [job ...]\n"84" at [-f file] -t [[CC]YY]MMDDhhmm[.SS]\n"85" at -r job [job ...]\n"86" at -l -q queuename\n"87" at -l [job ...]\n"88" atq [-q x] [-v]\n"89" atrm job [job ...]\n"90" batch [-f file] [-m]\n");91exit(EXIT_FAILURE);92}939495