summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-06-10 19:39:55 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-06-10 19:39:55 +0000
commitbc22af21398b80ff541f606958e06219732a0160 (patch)
treeeca23af43a0357b874820a97767cb214dc8e4773
parent4aca8c105a9fc533f16592ff4a765615621c1f9e (diff)
Disable progress meter if started as a bg process. Also don't
print the progress meter if the ftp process is put in the bg (but do print it when/if the process is foregrounded). From Enami Tsugutomo <enami@ba2.so-net.or.jp> with tweaks by me.
-rw-r--r--usr.bin/ftp/extern.h3
-rw-r--r--usr.bin/ftp/main.c6
-rw-r--r--usr.bin/ftp/util.c23
3 files changed, 25 insertions, 7 deletions
diff --git a/usr.bin/ftp/extern.h b/usr.bin/ftp/extern.h
index 43861ae48d3..7b6cac81058 100644
--- a/usr.bin/ftp/extern.h
+++ b/usr.bin/ftp/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.13 1997/04/23 20:33:04 deraadt Exp $ */
+/* $OpenBSD: extern.h,v 1.14 1997/06/10 19:39:53 millert Exp $ */
/* $NetBSD: extern.h,v 1.15 1997/04/14 09:09:17 lukem Exp $ */
/*-
@@ -69,6 +69,7 @@ char *domap __P((char *));
void doproxy __P((int, char **));
char *dotrans __P((char *));
int empty __P((struct fd_set *, int));
+int foregroundproc __P(());
void get __P((int, char **));
struct cmd *getcmd __P((const char *));
int getit __P((int, char **, int, const char *));
diff --git a/usr.bin/ftp/main.c b/usr.bin/ftp/main.c
index db032e248ab..ac879c23370 100644
--- a/usr.bin/ftp/main.c
+++ b/usr.bin/ftp/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.32 1997/06/01 22:30:49 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.33 1997/06/10 19:39:54 millert Exp $ */
/* $NetBSD: main.c,v 1.21 1997/04/05 03:27:39 lukem Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94";
#else
-static char rcsid[] = "$OpenBSD: main.c,v 1.32 1997/06/01 22:30:49 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.33 1997/06/10 19:39:54 millert Exp $";
#endif
#endif /* not lint */
@@ -120,7 +120,7 @@ main(argc, argv)
}
ttyout = stdout;
- if (isatty(fileno(ttyout)) && !dumb_terminal)
+ if (isatty(fileno(ttyout)) && !dumb_terminal && foregroundproc())
progress = 1; /* progress bar on if going to a tty */
if (!isatty(fileno(ttyout))) {
diff --git a/usr.bin/ftp/util.c b/usr.bin/ftp/util.c
index f8c650fd130..7a0f9325d54 100644
--- a/usr.bin/ftp/util.c
+++ b/usr.bin/ftp/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.9 1997/05/11 17:12:57 millert Exp $ */
+/* $OpenBSD: util.c,v 1.10 1997/06/10 19:39:54 millert Exp $ */
/* $NetBSD: util.c,v 1.7 1997/04/14 09:09:24 lukem Exp $ */
/*
@@ -35,7 +35,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: util.c,v 1.9 1997/05/11 17:12:57 millert Exp $";
+static char rcsid[] = "$OpenBSD: util.c,v 1.10 1997/06/10 19:39:54 millert Exp $";
#endif /* not lint */
/*
@@ -532,11 +532,28 @@ remotemodtime(file, noisy)
return (rtime);
}
+/*
+ * Returns true if this is the controlling/foreground process, else false.
+ */
+int
+foregroundproc()
+{
+ static pid_t pgrp = -1;
+ int ctty_pgrp;
+
+ if (pgrp == -1)
+ pgrp = getpgrp();
+
+ return((ioctl(STDOUT_FILENO, TIOCGPGRP, &ctty_pgrp) != -1 &&
+ ctty_pgrp == pgrp));
+}
+
void
updateprogressmeter()
{
- progressmeter(0);
+ if (foregroundproc())
+ progressmeter(0);
}
/*