diff options
author | Karel Zak | 2006-12-07 00:25:49 +0100 |
---|---|---|
committer | Karel Zak | 2006-12-07 00:25:49 +0100 |
commit | e8f2641919de90b488ce3788a7795b88311750b5 (patch) | |
tree | 68f3732da38ff1b21ec49780d7c830250329fec9 /misc-utils/script.c | |
parent | Imported from util-linux-2.11f tarball. (diff) | |
download | kernel-qcow2-util-linux-e8f2641919de90b488ce3788a7795b88311750b5.tar.gz kernel-qcow2-util-linux-e8f2641919de90b488ce3788a7795b88311750b5.tar.xz kernel-qcow2-util-linux-e8f2641919de90b488ce3788a7795b88311750b5.zip |
Imported from util-linux-2.11m tarball.
Diffstat (limited to 'misc-utils/script.c')
-rw-r--r-- | misc-utils/script.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/misc-utils/script.c b/misc-utils/script.c index de158cd35..973e80aa6 100644 --- a/misc-utils/script.c +++ b/misc-utils/script.c @@ -93,6 +93,7 @@ char line[] = "/dev/ptyXX"; int aflg = 0; int fflg = 0; int qflg = 0; +int tflg = 0; static char *progname; @@ -134,7 +135,7 @@ main(int argc, char **argv) { } } - while ((ch = getopt(argc, argv, "afq")) != EOF) + while ((ch = getopt(argc, argv, "afqt")) != EOF) switch((char)ch) { case 'a': aflg++; @@ -145,10 +146,13 @@ main(int argc, char **argv) { case 'q': qflg++; break; + case 't': + tflg++; + break; case '?': default: fprintf(stderr, - _("usage: script [-a] [-f] [-q] [file]\n")); + _("usage: script [-a] [-f] [-q] [-t] [file]\n")); exit(1); } argc -= optind; @@ -239,6 +243,8 @@ dooutput() { register int cc; time_t tvec; char obuf[BUFSIZ]; + struct timeval tv; + double oldtime=time(NULL), newtime; (void) close(0); #ifdef HAVE_openpty @@ -247,9 +253,16 @@ dooutput() { tvec = time((time_t *)NULL); fprintf(fscript, _("Script started on %s"), ctime(&tvec)); for (;;) { + if (tflg) + gettimeofday(&tv, NULL); cc = read(master, obuf, sizeof (obuf)); if (cc <= 0) break; + if (tflg) { + newtime=tv.tv_sec + (double) tv.tv_usec / 1000000; + fprintf(stderr, "%f %i\n", newtime - oldtime, cc); + oldtime=newtime; + } (void) write(1, obuf, cc); (void) fwrite(obuf, 1, cc, fscript); if (fflg) |