QProcess vs K3Process
Oswald Buddenhagen
ossi at kde.org
Tue May 29 22:17:52 BST 2007
On Tue, May 29, 2007 at 10:31:55PM +0200, Thiago Macieira wrote:
> > if timing matters, a common os-level channel is a must.
>
> Well, if timing matters, why are you running a separate process? With
> pipes no less? Shouldn't a thread be faster?
>
i didn't think about performance. if processes are concurrently
outputting stderr, the order of the messages might provide essential
clues.
another use case might be two processes outputting to a third process
(whether they coordinate or do it line-wise in random order is
irrelevant for the third process).
> >this time i *really* attached the mail to tt. (hey, i *did* say that i'm
> >in a hurry :)
>
> User-Agent: Mutt/1.5.15 (2007-04-13)
>
> Start using KMail :-)
>
i knew somebody would say that. :-P
when it provides an ui i can use over ssh without an x server. ;)
actually, i can have this "you wanted to attach something, bonehead!",
too, but i'm too lazy to set it up. :}
> >> Start every one? Yes, I think you want that. And it isn't difficult
> >> anyways, nor is there a particular order in which they must happen.
> >> The pipes are created when first needed and the remote end is open
> >> when the application starts (either in the parent or in the sibling
> >> process).
> >
> >yes, but why would you *want* to do it separately for every one?
>
> It takes the same number of lines or less.
>
> QProcess a, b, c;
> // set up the pipeline
> a.start("foo");
> b.start("bar");
> c.start("baz");
> or:
> QProcess a, b, c;
// set up programs
> KProcessGroup pg;
> // set up the pipeline
> a.joinProcessGroup(&pg);
> b.joinProcessGroup(&pg);
> c.joinProcessGroup(&pg);
> pg.start(); // or a.start();
>
think a bit further. ;)
KProcesGroup pg;
KProcess a(&pg), b(&pg), c(&pg);
// set up programs
// set up pipeline
pg.start();
or:
KProcessGroup pg;
pg << (QStringList() << "ls" << "-l");
pg << "less";
pg.start();
of course, waitForStarted()/waitForFinished() and even handling have to
be done for every process, too. this is very boring work and prone to
c&p-errors, simple logic errors, etc.
wouldn't you think KProcessGroup would be nice to have? ;)
--
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Chaos, panic, and disorder - my work here is done.
More information about the kde-core-devel
mailing list