[p4] Terminal output in p4v tools

Tetrick, Cary ctetrick at midway.com
Tue Nov 13 08:26:00 PST 2007


I found this out some time ago while working on my own tools. 
I'd be willing to bet that your custom tool would have sent output as
expected if you ran it stand alone from a command prompt.
It's likely that because P4v is capturing STDOUT, it's causing
buffering. 
Normally, STDOUT and STDERR when going to the OS console are treated as
a tty device, so no buffering occurs.
But the moment you redirect to a file (for example), output is
internally buffered. 
So flushing is a good practice. (In some cases, you can set things so
that it effectively never buffers.)

Cary

-----Original Message-----
From: perforce-user-bounces at perforce.com
[mailto:perforce-user-bounces at perforce.com] On Behalf Of Gross, Steve
Sent: Monday, November 12, 2007 3:29 PM
To: perforce-user at perforce.com
Subject: [p4] Terminal output in p4v tools

Hi folks. I had an interesting problem that you might find handy: my
custom tool generates a lot of output (both to stdout and stderr) during
an execution time of 10+ seconds. However, the p4v terminal window only
displayed ALL of the output at the END of execution, rather than
delivering the messages one by one as they occurred.

This had the unfortunate effect of making users wonder whether the
program was running at all! That is, they would spawn the tool, get an
empty terminal window, and no output for awhile. Ack!

I found an interesting solution: after every message is delivered (er,
printed) to stdout or stderr in my tool, I flush the appropriate buffer.
This works like a charm!

Interesting, huh?

--Steve

_______________________________________________
perforce-user mailing list  -  perforce-user at perforce.com
http://maillist.perforce.com/mailman/listinfo/perforce-user



More information about the perforce-user mailing list