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

List:       kde-core-devel
Subject:    Re: KProcess eats SIGCHLD, so pclose() fails
From:       aleXXX <alexander.neundorf () gmx ! net>
Date:       2001-11-28 18:18:28
[Download RAW message or body]

On Wed 28 Nov 01 18:32, David Faure wrote:
> KProcessController, instantiated by KProcess, seems to grab all SIGCHLD
> events, even the ones that have nothing to do with KProcess.

After looking at the code, it grabs exactly SIGCHLD and SIGPIPE since it has 
to know when its child dies. And it probably is only caught as long as a 
KProcess exists.

> For instance I'm using popen() and pclose(), and the pclose() returns -1
> with errno set to "no child process", due to this.
>
> See the attached testcase, to be compiled with
> g++ -I$QTDIR/include -L$QTDIR/lib popenkde.cpp -o popenkde -lqt -lkdecore
> And run "./popenkde blah" (blah being the executable that doesn't exist ;)
> Before the KProcess creation, the test works fine, after it it doesn't.
>
> Is there anything that can be done about this ? (I'm no kprocess / unix
> signal expert). Or do we really require all code run in a KDE application,
> to use KProcess instead of popen/pclose ? This makes it hard to use
> 3rd-party libraries, in e.g. a KPart, since konqueror uses KProcess for
> other things.

You could ignore that pclose() returns -1. Probably there is also a way to 
get the pids of all child processes, then you could test them with wait() or 
something.
Do you want to run arbitrary "unknown" programs or a special program ?
Usually stdout is closed when the program exits, so if you detect that the 
pipe was closed the app has usually already quit. Then pclose() can't fail.

Bye
Alex

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

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