Last KProcess commit broke things (namely K3B)

Oswald Buddenhagen ossi at
Fri Jan 16 23:06:27 GMT 2004

On Fri, Jan 16, 2004 at 09:20:57PM +0200, Andras Mantia wrote:
>  I think this is really a showstopper after a fix for a showstopper... Without 
> the attached patch (which is a revert of Ossi's fix) you cannot write data 
> CD's anymore with K3B, as mkisofs will complain:
>   Resource temporarily unavailable. cannot fwrite 32768*1
ok, problem identified. the attached patch should fix it - untested.

the situation:
- k3b spawns cdrecord with full io redirection. consequently (with my
  kdecore patch), the parent process' end of the stdin socketpair is set
  to non-blocking operation.
- after that, k3b spawns mkisofs. the culprit is, that it duplicates the
  parent's stdin end of the other process directly to this process'
  stdout. in itself this is no problem. however, the file descriptor
  which is duped here was set up by kprocess for its own purposes; no
  specific properties of it are documented. in fact, this already
  changed once in the other direction in kde 3.1 (the commented out code
  in k3bprocess documents this).

essentially the problem is kprocess' poor encapsulation, which seduces to
making assumptions ...
i plan to rewrite the kprocess api for kde 4, but for now we are stuck
with two suboptimal solutions:
- keep kprocess, declare k3b buggy and patch it
- keep k3b, revert kprocess, document that writeStdin supports at most
  4K big blocks (at least on linux that's the pipe buffer's size) and
  patch konsole accordingly. however, this is still not warranteed to
  work always - if the other end does not read the entire buffer at
  once, we still may end up with a blocking write and a deadlock.
ergo, i vote for the first solution ...


Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
Chaos, panic, and disorder - my work here is done.
-------------- next part --------------
Index: k3bprocess.cpp
RCS file: /home/kde/kdeextragear-1/k3b/src/core/k3bprocess.cpp,v
retrieving revision 1.12
diff -U2 -r1.12 k3bprocess.cpp
--- k3bprocess.cpp	14 Jan 2004 21:35:07 -0000	1.12
+++ k3bprocess.cpp	16 Jan 2004 23:05:36 -0000
@@ -318,4 +318,5 @@
     if( ::dup2( d->dupStdoutFd, STDOUT_FILENO ) != -1 ) {
       kdDebug() << "(K3bProcess) Successfully duplicated " << d->dupStdoutFd << " to " << STDOUT_FILENO << endl;
+      ::fcntl( STDOUT_FILENO, F_SETFL, ~O_NONBLOCK & fcntl( STDOUT_FILENO, F_GETFL ) ); // assume that this cannot fail
     else {

More information about the kde-core-devel mailing list