public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* stpd and stdout
@ 2006-05-09 22:21 Hien Nguyen
  2006-05-18 17:56 ` Martin Hunt
  0 siblings, 1 reply; 4+ messages in thread
From: Hien Nguyen @ 2006-05-09 22:21 UTC (permalink / raw)
  To: Martin Hunt, SystemTAP

Hi Martin,

While working on the the systemtap GUI we run into the problem of 
getting the stdout to the gui app in a timely fashion. We does get the 
output as a blob of text once in a while (looks like data were only 
flushed out when the buffer is full). To recreate the problem you can 
try this

stap -e 'probe syscall.open{ log(filename) }' | tee

Anyway, I added one line of code to flushout the data as soon as the 
stpd gets it. It seems to solve the above problem. To avoid unnecessary 
performance issues for others, perhaps we should have that as an option. 
What do you think?

Thanks, Hien.

--- librelay.c  2006-05-09 14:49:07.000000000 -0700
+++ librelay.c.new      2006-05-09 14:34:48.000000000 -0700
@@ -789,6 +789,7 @@
                }
                case STP_REALTIME_DATA:
                        fwrite_unlocked(data, nb - sizeof(int), 1, ofp);
+                       fflush_unlocked(ofp);
                        break;
                case STP_OOB_DATA:
                        fputs ((char *)data, stderr);


^ permalink raw reply	[flat|nested] 4+ messages in thread
* RE: stpd and stdout
@ 2006-05-09 22:57 Stone, Joshua I
  0 siblings, 0 replies; 4+ messages in thread
From: Stone, Joshua I @ 2006-05-09 22:57 UTC (permalink / raw)
  To: Hien Nguyen, Martin Hunt, SystemTAP

On Tuesday, May 09, 2006 3:21 PM, Hien Nguyen wrote:
> While working on the the systemtap GUI we run into the problem of
> getting the stdout to the gui app in a timely fashion. We does get the
> output as a blob of text once in a while (looks like data were only
> flushed out when the buffer is full). To recreate the problem you can
> try this
> 
> stap -e 'probe syscall.open{ log(filename) }' | tee
> 
> Anyway, I added one line of code to flushout the data as soon as the
> stpd gets it. It seems to solve the above problem. To avoid
> unnecessary performance issues for others, perhaps we should have
> that as an option. What do you think?

I've run into this with Perl scripts before -- Perl normally
line-buffers output to STDOUT and block-buffers otherwise (e.g. to a
pipe or socket).  Their solution for this problem is an autoflush
option:
http://perldoc.perl.org/perlvar.html#HANDLE->autoflush(EXPR)

I think it would be very reasonable to support a similar command-line
option in stap/stpd.


Josh

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-05-18 20:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-09 22:21 stpd and stdout Hien Nguyen
2006-05-18 17:56 ` Martin Hunt
2006-05-18 20:42   ` Hien Nguyen
2006-05-09 22:57 Stone, Joshua I

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).