summaryrefslogtreecommitdiffstats
path: root/usr.bin/script
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/script')
-rw-r--r--usr.bin/script/script.19
-rw-r--r--usr.bin/script/script.c20
2 files changed, 22 insertions, 7 deletions
diff --git a/usr.bin/script/script.1 b/usr.bin/script/script.1
index 9b8efcd..de8e7ff 100644
--- a/usr.bin/script/script.1
+++ b/usr.bin/script/script.1
@@ -28,7 +28,7 @@
.\" @(#)script.1 8.1 (Berkeley) 6/6/93
.\" $FreeBSD$
.\"
-.Dd Oct 27, 2012
+.Dd December 4, 2013
.Dt SCRIPT 1
.Os
.Sh NAME
@@ -37,6 +37,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl adfkpqr
+.Op Fl F Ar pipe
.Op Fl t Ar time
.Op Ar file Op Ar command ...
.Sh DESCRIPTION
@@ -76,6 +77,12 @@ retaining the prior contents.
When playing back a session with the
.Fl p
flag, do not sleep between records when playing back a timestamped session.
+.It Fl F Ar pipe
+Immediately flush output after each write.
+This will allow a user to create a named pipe using
+.Xr mkfifo 1
+and another user may watch the live session using a utility like
+.Xr cat 1 .
.It Fl f
Create
.Ar file.filemon
diff --git a/usr.bin/script/script.c b/usr.bin/script/script.c
index 515a10e..72814fb 100644
--- a/usr.bin/script/script.c
+++ b/usr.bin/script/script.c
@@ -98,18 +98,18 @@ main(int argc, char *argv[])
char obuf[BUFSIZ];
char ibuf[BUFSIZ];
fd_set rfd;
- int aflg, kflg, pflg, ch, k, n;
+ int aflg, Fflg, kflg, pflg, ch, k, n;
int flushtime, readstdin;
int fm_fd, fm_log;
- aflg = kflg = pflg = 0;
+ aflg = Fflg = kflg = pflg = 0;
usesleep = 1;
rawout = 0;
flushtime = 30;
fm_fd = -1; /* Shut up stupid "may be used uninitialized" GCC
warning. (not needed w/clang) */
- while ((ch = getopt(argc, argv, "adfkpqrt:")) != -1)
+ while ((ch = getopt(argc, argv, "adFfkpqrt:")) != -1)
switch(ch) {
case 'a':
aflg = 1;
@@ -117,6 +117,9 @@ main(int argc, char *argv[])
case 'd':
usesleep = 0;
break;
+ case 'F':
+ Fflg = 1;
+ break;
case 'f':
fflg = 1;
break;
@@ -235,12 +238,15 @@ main(int argc, char *argv[])
FD_SET(master, &rfd);
if (readstdin)
FD_SET(STDIN_FILENO, &rfd);
- if ((!readstdin && ttyflg) || flushtime > 0) {
- tv.tv_sec = !readstdin && ttyflg ? 1 :
- flushtime - (tvec - start);
+ if (!readstdin && ttyflg) {
+ tv.tv_sec = 1;
tv.tv_usec = 0;
tvp = &tv;
readstdin = 1;
+ } else if (flushtime > 0) {
+ tv.tv_sec = flushtime - (tvec - start);
+ tv.tv_usec = 0;
+ tvp = &tv;
} else {
tvp = NULL;
}
@@ -283,6 +289,8 @@ main(int argc, char *argv[])
fflush(fscript);
start = tvec;
}
+ if (Fflg)
+ fflush(fscript);
}
finish();
done(0);
OpenPOWER on IntegriCloud