[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: KProcess, KProcIO & buffered reading
From:       Tim Lee <tlee () tc ! fluke ! com>
Date:       2001-11-06 0:16:35
[Download RAW message or body]

On Monday 05 November 2001 06:52 am, Nene wrote:
> Hi,
>
> I've found a problem in the kprocess.cpp. If I try to run a program like:
> for (int i=10;i-->0;) {
> 	cout << "stdout\n";
> 	cerr << "stderr\n";
> }
> the output will be 10x stdout and then 10x stderr, not 10x mixed
> stdout,stderr. This is cause a buffered reading in kprocess.cpp. Of course
> this bug is also in kprocio.
> Have you any suggestions how can I get a correct output??

Actually I believe the problem is that stdout is block buffered
while stderr is not buffered at all when you are connected to the
parent process with UNIX domain sockets.  I am currently just
finishing work on KProcess to integrate psuedo TTY output from
the child to the parent which alows the output to look just like
if you run the command from a terminal.  The stdout will be line
buffered while the stderr will not be buffered.

The devel is done I just have to port it over to KDE 3 and then
I'll see if people want to add it.  The results of running this
command with and without using TTY output is shown below
respectively:

p.start(KProcess::NotifyOnExit, 
        KProcess::Communication(KProcess::AllOutput))

stderr
stderr
stderr
stderr
stderr
stderr
stderr
stderr
stderr
stderr
stdout
stdout
stdout
stdout
stdout
stdout
stdout
stdout
stdout
stdout
   Process 29338 exited!


p.start(KProcess::NotifyOnExit, 
        KProcess::Communication(KProcess::AllOutput|
        KProcess::UseTty|KProcess::TieOutput))

stdout
stderr
stdout
stderr
stdout
stderr
stdout
stderr
stdout
stderr
stdout
stderr
stdout
stderr
stdout
stderr
stdout
stderr
stdout
stderr
   Process 29339 exited!

Regards,

>
> 	Nene
>
> >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to
> >> unsubscribe <<

-- 
Tim Lee
R&D Design Engineer
Fluke Networks
6805 Corporate Drive, Suite 100
Colorado Springs, CO 80919
www.flukenetworks.com
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic