[repost] Patch to make cpdup's stdout unbuffered

看板DFBSD_submit作者時間21年前 (2004/06/09 13:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/9 (看更多)
This is a multi-part message in MIME format. --Multipart=_Tue__8_Jun_2004_14_02_08_-0700_0XDhtA0SH4nS3FQd Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit [reposting this, as I sent it 2.5 hours ago but nothing's come through, whereas my post to bugs@ came back to me in minutes - apologies for any duplicates] Hey again, The attached patch adds a new option to cpdup, -u, which causes cpdup's logging output to be unbuffered. Since this could rightly be perceived as a bit of feature creep, I'll try to explain why it's useful in the installer: The installer popen()'s "cpdup -vvv src dest" and it reads from this pipe to monitor cpdup's progress. Unfortunately, since cpdup's output is fully buffered, cpdup's progress can't be usefully measured this way. This patch simply gives us a way to make cpdup's output unbuffered, so we can get it through the pipe as cpdup generates it. If there are no objections, I'll commit this in two days. -Chris --Multipart=_Tue__8_Jun_2004_14_02_08_-0700_0XDhtA0SH4nS3FQd Content-Type: text/plain; name="cpdup-flush.diff" Content-Disposition: attachment; filename="cpdup-flush.diff" Content-Transfer-Encoding: 7bit Index: bin/cpdup/cpdup.1 =================================================================== RCS file: /home/dcvs/src/bin/cpdup/cpdup.1,v retrieving revision 1.3 diff -u -r1.3 cpdup.1 --- bin/cpdup/cpdup.1 19 Mar 2004 07:46:46 -0000 1.3 +++ bin/cpdup/cpdup.1 8 Jun 2004 18:29:43 -0000 @@ -13,6 +13,7 @@ .Sh SYNOPSIS .Nm cpdup .Op Fl v[vv..] +.Op Fl u .Op Fl I .Op Fl f .Op Fl s0 @@ -62,6 +63,11 @@ .Fl vvv will cause all files and directories to be reported whether or not modifications are made. +.It Fl u +Causes the ouptut generated by +.Fl v[vv] +to be unbuffered. +This can be useful for obtaining prompt progress updates through a pipe. .It Fl I will cause cpdup to print a summary at the end with performance counter. .It Fl f Index: bin/cpdup/cpdup.c =================================================================== RCS file: /home/dcvs/src/bin/cpdup/cpdup.c,v retrieving revision 1.3 diff -u -r1.3 cpdup.c --- bin/cpdup/cpdup.c 19 Mar 2004 17:30:59 -0000 1.3 +++ bin/cpdup/cpdup.c 8 Jun 2004 18:23:19 -0000 @@ -204,6 +204,9 @@ UseMD5Opt = v; MD5CacheFile = ".MD5.CHECKSUMS"; break; + case 'u': + setvbuf(stdout, NULL, _IONBF, 0); + break; default: fatal("illegal option: %s\n", ptr - 2); /* not reached */ Index: bin/cpdup/misc.c =================================================================== RCS file: /home/dcvs/src/bin/cpdup/misc.c,v retrieving revision 1.3 diff -u -r1.3 misc.c --- bin/cpdup/misc.c 19 Mar 2004 17:30:59 -0000 1.3 +++ bin/cpdup/misc.c 8 Jun 2004 18:25:05 -0000 @@ -48,6 +48,7 @@ if (ctl == NULL) { puts("cpdup [<options>] src [dest]"); puts(" -v[vv] verbose level (-vv is typical)\n" + " -u use unbuffered output for -v[vv]\n" " -I display performance summary\n" " -f force update even if files look the same\n" " -i0 do NOT confirm when removing something\n" --Multipart=_Tue__8_Jun_2004_14_02_08_-0700_0XDhtA0SH4nS3FQd--
文章代碼(AID): #10ng3M00 (DFBSD_submit)
討論串 (同標題文章)
文章代碼(AID): #10ng3M00 (DFBSD_submit)