mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-01 12:19:28 +00:00
Use err(3).
This commit is contained in:
parent
885a85b6c1
commit
7eb436730f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=27785
@ -41,12 +41,12 @@
|
||||
.Nm nohup
|
||||
.Nd invoke a command immune to hangups
|
||||
.Sh SYNOPSIS
|
||||
.Nm nohup
|
||||
.Nm
|
||||
.Ar command
|
||||
.Op Ar arg ...
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm nohup
|
||||
.Nm
|
||||
utility invokes
|
||||
.Ar command
|
||||
with
|
||||
@ -75,7 +75,7 @@ The following variable is utilized by
|
||||
If the output file
|
||||
.Pa nohup.out
|
||||
cannot be created in the current directory, the
|
||||
.Nm nohup
|
||||
.Nm
|
||||
utility uses the directory named by
|
||||
.Ev HOME
|
||||
to create the file.
|
||||
@ -84,7 +84,7 @@ to create the file.
|
||||
.Xr signal 3
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Nm nohup
|
||||
command is expected to be
|
||||
.Nm
|
||||
utility is expected to be
|
||||
.St -p1003.2
|
||||
compatible.
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user