diff options
author | charnier <charnier@FreeBSD.org> | 1997-07-31 06:54:45 +0000 |
---|---|---|
committer | charnier <charnier@FreeBSD.org> | 1997-07-31 06:54:45 +0000 |
commit | 7364d57a33f05735b331f030725be112b17635e5 (patch) | |
tree | d686598fc059b1d80562eb8b86e214f809409191 /usr.bin/nohup/nohup.c | |
parent | 7714fda3a9641058c32a360d1fc998bd43a9bcb3 (diff) | |
download | FreeBSD-src-7364d57a33f05735b331f030725be112b17635e5.zip FreeBSD-src-7364d57a33f05735b331f030725be112b17635e5.tar.gz |
Use err(3).
Diffstat (limited to 'usr.bin/nohup/nohup.c')
-rw-r--r-- | usr.bin/nohup/nohup.c | 24 |
1 files changed, 12 insertions, 12 deletions
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 <sys/param.h> #include <sys/stat.h> +#include <err.h> #include <errno.h> #include <fcntl.h> #include <signal.h> @@ -53,7 +58,7 @@ static char sccsid[] = "@(#)nohup.c 8.1 (Berkeley) 6/6/93"; #include <unistd.h> 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); } |