summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormickey <mickey@openbsd.org>2001-08-19 18:54:47 +0000
committermickey <mickey@openbsd.org>2001-08-19 18:54:47 +0000
commit4ee727b81bad2b50c933dc8a787eafe11169b9a0 (patch)
tree90f1724ed6487db7b679a82ca97c79e55dde4bd0
parentscsi, no devices yet. (diff)
downloadwireguard-openbsd-4ee727b81bad2b50c933dc8a787eafe11169b9a0.tar.xz
wireguard-openbsd-4ee727b81bad2b50c933dc8a787eafe11169b9a0.zip
use err/errx, spaces
-rw-r--r--usr.bin/nohup/nohup.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/usr.bin/nohup/nohup.c b/usr.bin/nohup/nohup.c
index 99ba18d3f56..861a63354de 100644
--- a/usr.bin/nohup/nohup.c
+++ b/usr.bin/nohup/nohup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nohup.c,v 1.6 2000/08/02 04:10:49 millert Exp $ */
+/* $OpenBSD: nohup.c,v 1.7 2001/08/19 18:54:47 mickey Exp $ */
/* $NetBSD: nohup.c,v 1.6 1995/08/31 23:35:25 jtc Exp $ */
/*
@@ -44,7 +44,7 @@ char copyright[] =
#if 0
static char sccsid[] = "@(#)nohup.c 5.4 (Berkeley) 6/1/90";
#endif
-static char rcsid[] = "$OpenBSD: nohup.c,v 1.6 2000/08/02 04:10:49 millert Exp $";
+static char rcsid[] = "$OpenBSD: nohup.c,v 1.7 2001/08/19 18:54:47 mickey Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -57,6 +57,7 @@ static char rcsid[] = "$OpenBSD: nohup.c,v 1.6 2000/08/02 04:10:49 millert Exp $
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <err.h>
static void dofile();
static void usage();
@@ -93,8 +94,7 @@ main(argc, argv)
execvp(argv[1], &argv[1]);
exit_status = (errno == ENOENT) ? EXIT_NOTFOUND : EXIT_NOEXEC;
- (void)fprintf(stderr, "nohup: %s: %s\n", argv[1], strerror(errno));
- exit(exit_status);
+ err(exit_status, argv[1]);
}
static void
@@ -103,11 +103,11 @@ dofile()
int fd;
char *p, path[MAXPATHLEN];
- /* If the standard output is a terminal, all output written to
+ /* If the standard output is a terminal, all output written to
its standard output shall be appended to the end of the file
nohup.out in the current directory. If nohup.out cannot be
created or opened for appending, the output shall be appended
- to the end of the file nohup.out in the directory specified
+ to the end of the file nohup.out in the directory specified
by the HOME environment variable.
If a file is created, the file's permission bits shall be
@@ -124,14 +124,11 @@ dofile()
if ((fd = open(p = path, O_RDWR|O_CREAT|O_APPEND, S_IRUSR|S_IWUSR)) >= 0)
goto dupit;
}
- (void)fprintf(stderr, "nohup: can't open a nohup.out file.\n");
- exit(EXIT_MISC);
+ errx(EXIT_MISC, "can't open a nohup.out file");
dupit: (void)lseek(fd, 0, SEEK_END);
- if (dup2(fd, STDOUT_FILENO) == -1) {
- (void)fprintf(stderr, "nohup: %s\n", strerror(errno));
- exit(EXIT_MISC);
- }
+ if (dup2(fd, STDOUT_FILENO) == -1)
+ err(EXIT_MISC, NULL);
(void)fprintf(stderr, "sending output to %s\n", p);
}