aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/nohup
diff options
context:
space:
mode:
authorTim Vanderhoek <hoek@FreeBSD.org>1999-05-22 06:57:22 +0000
committerTim Vanderhoek <hoek@FreeBSD.org>1999-05-22 06:57:22 +0000
commit6e01d46b30aa97c74ed4b90c006c3bd521eaf0bd (patch)
tree55e81e6ece8231438f73c01dec1fe49bc9b281c3 /usr.bin/nohup
parenta1684b9830fc4e19ebe33c935218482a63b91195 (diff)
downloadsrc-6e01d46b30aa97c74ed4b90c006c3bd521eaf0bd.tar.gz
src-6e01d46b30aa97c74ed4b90c006c3bd521eaf0bd.zip
If we're going to do such a non-UNIX(tm)y thing as appending output
to a file instead of truncating, at least word the notice of output redirection appropriately.
Notes
Notes: svn path=/head/; revision=47385
Diffstat (limited to 'usr.bin/nohup')
-rw-r--r--usr.bin/nohup/nohup.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/usr.bin/nohup/nohup.c b/usr.bin/nohup/nohup.c
index 7b32e2ff02ae..3455c7cb797e 100644
--- a/usr.bin/nohup/nohup.c
+++ b/usr.bin/nohup/nohup.c
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)nohup.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$Id$";
+ "$Id: nohup.c,v 1.2 1997/07/31 06:54:45 charnier Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -86,17 +86,20 @@ main(argc, argv)
void
dofile()
{
+ int append;
int fd;
char *p, path[MAXPATHLEN];
#define FILENAME "nohup.out"
p = FILENAME;
+ append = !access(p, F_OK);
if ((fd = open(p, O_RDWR|O_CREAT, S_IRUSR | S_IWUSR)) >= 0)
goto dupit;
if ((p = getenv("HOME"))) {
(void)strcpy(path, p);
(void)strcat(path, "/");
(void)strcat(path, FILENAME);
+ append = !access(path, F_OK);
if ((fd = open(p = path,
O_RDWR|O_CREAT, S_IRUSR | S_IWUSR)) >= 0)
goto dupit;
@@ -106,7 +109,10 @@ dofile()
dupit: (void)lseek(fd, (off_t)0, SEEK_END);
if (dup2(fd, STDOUT_FILENO) == -1)
err(1, NULL);
- (void)fprintf(stderr, "sending output to %s\n", p);
+ if (append)
+ (void)fprintf(stderr, "appending output to existing %s\n", p);
+ else
+ (void)fprintf(stderr, "sending output to %s\n", p);
}
void