Use err(3).

This commit is contained in:
Philippe Charnier 1997-06-19 14:28:32 +00:00
parent 904058d0ad
commit a2bfcdfd76
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=26737

View File

@ -29,6 +29,8 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
*
* $Id$
*/ */
#ifndef lint #ifndef lint
@ -55,6 +57,7 @@ static char sccsid[] = "@(#)shutdown.c 8.2 (Berkeley) 2/16/94";
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <err.h>
#include "pathnames.h" #include "pathnames.h"
@ -104,10 +107,8 @@ main(argc, argv)
int arglen, ch, len, readstdin; int arglen, ch, len, readstdin;
#ifndef DEBUG #ifndef DEBUG
if (geteuid()) { if (geteuid())
(void)fprintf(stderr, "shutdown: NOT super-user\n"); errx(1, "NOT super-user");
exit(1);
}
#endif #endif
nosync = NULL; nosync = NULL;
readstdin = 0; readstdin = 0;
@ -139,8 +140,7 @@ main(argc, argv)
usage(); usage();
if (doreboot && dohalt) { if (doreboot && dohalt) {
(void)fprintf(stderr, warnx("incompatible switches -h and -r.");
"shutdown: incompatible switches -h and -r.\n");
usage(); usage();
} }
getoffset(*argv++); getoffset(*argv++);
@ -191,14 +191,10 @@ main(argc, argv)
int forkpid; int forkpid;
forkpid = fork(); forkpid = fork();
if (forkpid == -1) { if (forkpid == -1)
perror("shutdown: fork"); err(1, "fork");
exit(1); if (forkpid)
} errx(0, "[pid %d]", forkpid);
if (forkpid) {
(void)printf("shutdown: [pid %d]\n", forkpid);
exit(0);
}
} }
#endif #endif
openlog("shutdown", LOG_CONS, LOG_AUTH); openlog("shutdown", LOG_CONS, LOG_AUTH);
@ -406,11 +402,8 @@ getoffset(timearg)
lt->tm_sec = 0; lt->tm_sec = 0;
if ((shuttime = mktime(lt)) == -1) if ((shuttime = mktime(lt)) == -1)
badtime(); badtime();
if ((offset = shuttime - now) < 0) { if ((offset = shuttime - now) < 0)
(void)fprintf(stderr, errx(1, "that time is already past.");
"shutdown: that time is already past.\n");
exit(1);
}
break; break;
default: default:
badtime(); badtime();
@ -451,8 +444,7 @@ finish(signo)
void void
badtime() badtime()
{ {
(void)fprintf(stderr, "shutdown: bad time format.\n"); errx(1, "bad time format.");
exit(1);
} }
void void