QProcess vs K3Process
Thiago Macieira
thiago at kde.org
Tue May 29 21:31:55 BST 2007
Oswald Buddenhagen wrote:
>On Tue, May 29, 2007 at 07:19:25PM +0200, Thiago Macieira wrote:
>> Maybe a separate class then? KShellProcess or something similar.
>
>been there, done that, got the t-shirt. k3shellprocess is scheduled for
>deletion for years; i'm pondering with deleting it finally.
>this is exactly the kind of "feature fragmentation" which made me
>sceptical wrt splitting off kptyprocess: suppose you want pty *and*
>shell. whoops. i think outsourcing ptys makes more sense ...
You want to have the cake and eat it too? Sheesh :-)
>> Ok, I see. You want
>> foo | bar >/dev/null
>>
>> And you want to collect stderr from both processes, merged. I see the
>> use-case, but I would argue that it's in fact better to collect them
>> separately. That way, if an error is reported, the application can
>> identify which process did it.
>
>depends on the use case. 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 don't agree with the need for merged/munged stderr output from a
pipeline.
>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 was using Squirrelmail in a few emails in this thread, though]
>> 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;
KProcessGroup pg;
// set up the pipeline
a.joinProcessGroup(&pg);
b.joinProcessGroup(&pg);
c.joinProcessGroup(&pg);
pg.start(); // or a.start();
>anyway, as i noted, the case for os-level process groups is really weak;
>i won't insist. but KProcessGroup as a convenience class (we want to
>keep people away from setUseShell(), right? ;) sure makes sense.
Well, I don't agree, but let's see how the users of this code actually
fare.
>actually, it is possible:
[Going off-topic]
>(A|B) 2>&1 >(C) | D
>yes, this is bash and needs named pipes. but you get the idea. :)
Almost. I managed this with zsh:
$ touch foo
$ ls -l foo bar 2> >(cat > stderr) | cat > stdout
$ cat stderr
ls: bar: No such file or directory
$ cat stdout
-rw-r--r-- 1 thiago thiago 0 Mai 29 22:24 foo
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070529/06ca0da9/attachment.sig>
More information about the kde-core-devel
mailing list