=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/nohup/nohup.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- src/usr.bin/nohup/nohup.c 2000/08/02 04:10:49 1.6 +++ src/usr.bin/nohup/nohup.c 2001/08/19 18:54:47 1.7 @@ -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 @@ #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 @@ -57,6 +57,7 @@ #include #include #include +#include static void dofile(); static void usage(); @@ -93,8 +94,7 @@ 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 @@ 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 @@ 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); }