version 1.6, 2000/08/02 04:10:49 |
version 1.7, 2001/08/19 18:54:47 |
|
|
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
#include <errno.h> |
#include <errno.h> |
|
#include <err.h> |
|
|
static void dofile(); |
static void dofile(); |
static void usage(); |
static void usage(); |
|
|
|
|
execvp(argv[1], &argv[1]); |
execvp(argv[1], &argv[1]); |
exit_status = (errno == ENOENT) ? EXIT_NOTFOUND : EXIT_NOEXEC; |
exit_status = (errno == ENOENT) ? EXIT_NOTFOUND : EXIT_NOEXEC; |
(void)fprintf(stderr, "nohup: %s: %s\n", argv[1], strerror(errno)); |
err(exit_status, argv[1]); |
exit(exit_status); |
|
} |
} |
|
|
static void |
static void |
|
|
int fd; |
int fd; |
char *p, path[MAXPATHLEN]; |
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 |
its standard output shall be appended to the end of the file |
nohup.out in the current directory. If nohup.out cannot be |
nohup.out in the current directory. If nohup.out cannot be |
created or opened for appending, the output shall be appended |
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. |
by the HOME environment variable. |
|
|
If a file is created, the file's permission bits shall be |
If a file is created, the file's permission bits shall be |
|
|
if ((fd = open(p = path, O_RDWR|O_CREAT|O_APPEND, S_IRUSR|S_IWUSR)) >= 0) |
if ((fd = open(p = path, O_RDWR|O_CREAT|O_APPEND, S_IRUSR|S_IWUSR)) >= 0) |
goto dupit; |
goto dupit; |
} |
} |
(void)fprintf(stderr, "nohup: can't open a nohup.out file.\n"); |
errx(EXIT_MISC, "can't open a nohup.out file"); |
exit(EXIT_MISC); |
|
|
|
dupit: (void)lseek(fd, 0, SEEK_END); |
dupit: (void)lseek(fd, 0, SEEK_END); |
if (dup2(fd, STDOUT_FILENO) == -1) { |
if (dup2(fd, STDOUT_FILENO) == -1) |
(void)fprintf(stderr, "nohup: %s\n", strerror(errno)); |
err(EXIT_MISC, NULL); |
exit(EXIT_MISC); |
|
} |
|
(void)fprintf(stderr, "sending output to %s\n", p); |
(void)fprintf(stderr, "sending output to %s\n", p); |
} |
} |
|
|