From 7364d57a33f05735b331f030725be112b17635e5 Mon Sep 17 00:00:00 2001 From: charnier Date: Thu, 31 Jul 1997 06:54:45 +0000 Subject: Use err(3). --- usr.bin/nohup/nohup.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'usr.bin/nohup/nohup.c') diff --git a/usr.bin/nohup/nohup.c b/usr.bin/nohup/nohup.c index d469a13..7b32e2f 100644 --- a/usr.bin/nohup/nohup.c +++ b/usr.bin/nohup/nohup.c @@ -32,18 +32,23 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1989, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint +#if 0 static char sccsid[] = "@(#)nohup.c 8.1 (Berkeley) 6/6/93"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ #include #include +#include #include #include #include @@ -53,7 +58,7 @@ static char sccsid[] = "@(#)nohup.c 8.1 (Berkeley) 6/6/93"; #include void dofile __P((void)); -void usage __P((void)); +static void usage __P((void)); int main(argc, argv) @@ -75,9 +80,7 @@ main(argc, argv) (void)signal(SIGQUIT, SIG_IGN); execvp(argv[1], &argv[1]); - (void)fprintf(stderr, - "nohup: %s: %s\n", argv[1], strerror(errno)); - exit(1); + err(1, "%s", argv[1]); } void @@ -90,7 +93,7 @@ dofile() p = FILENAME; if ((fd = open(p, O_RDWR|O_CREAT, S_IRUSR | S_IWUSR)) >= 0) goto dupit; - if (p = getenv("HOME")) { + if ((p = getenv("HOME"))) { (void)strcpy(path, p); (void)strcat(path, "/"); (void)strcat(path, FILENAME); @@ -98,14 +101,11 @@ dofile() O_RDWR|O_CREAT, S_IRUSR | S_IWUSR)) >= 0) goto dupit; } - (void)fprintf(stderr, "nohup: can't open a nohup.out file.\n"); - exit(1); + errx(1, "can't open a nohup.out file"); dupit: (void)lseek(fd, (off_t)0, SEEK_END); - if (dup2(fd, STDOUT_FILENO) == -1) { - (void)fprintf(stderr, "nohup: %s\n", strerror(errno)); - exit(1); - } + if (dup2(fd, STDOUT_FILENO) == -1) + err(1, NULL); (void)fprintf(stderr, "sending output to %s\n", p); } -- cgit v1.1