You are not logged in.

Dear visitor, welcome to KDE-Forum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

SmartyHias

Beginner

  • "SmartyHias" started this thread

Posts: 2

Location: Munich - Germany

Occupation: Computer freak

  • Send private message

1

Friday, December 17th 2004, 12:47pm

KProcess doesn't launch child process while debugging.

Hi there !

I need to launch an application from within my application. Since I also need to be informed, when the child process exits (ie crashes etc.) I want to use the KProcess class.
It works perfectly as long as I am not starting it in debugging mode from within KDevelop. When I want to debug my application, then it just won't start the child process. I have found some statements on the internet, saying, that this is a known Problem, but I haven't found a solution to it yet.
You can try it very simply in your own application. Just add the following lines somewhere in your code (plus #include <kprocess.h> of course). When you start your application from commandline it launches kwrite. In debugging mode it won't.

Quoted


KProcess procTest;
procTest << "kwrite";
procTest.start(KProcess::DontCare);


I would appreciate some tips how to avoid this problem, since I really need to debug my code :-)

SmartyHias

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

2

Friday, December 17th 2004, 5:16pm

Just to make sure: your process instance is created on the heap somewhere or a member of another class and stays around, does it?
Your code snippet looks like a local variable which will be deleted when the method returns.

Cheers,
_
Qt/KDE Developer
Debian User

SmartyHias

Beginner

  • "SmartyHias" started this thread

Posts: 2

Location: Munich - Germany

Occupation: Computer freak

  • Send private message

3

Friday, December 17th 2004, 5:59pm

Well, I also checked this. It doesn't matter if I instantiate the object by "new" or just as a local instance. Especially if I am starting the process with "KProcess::DontCare".
Besides it works perfectly fine when staring the application from shell. It just seizes to work when starting it with gdb. KDE-gdb or ddd-gdb doesn't make a difference.
You can try it yourself real quick, if you want. Just make a new project using a simple KDE-Application (Hello world or so). insert the 3 lines in the c-tor of your KMainWindow derived class. (it also doesn't matter if you put it into the c-tor or eg. a slot :-) ). build it and run it from a shell first and then using gdb.
Funny, but nasty little bug :-)

Have a nice evening

SmartyHias