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.

1

Tuesday, June 7th 2005, 10:09pm

kstart child PID

Hi .

I am writing an editor for Linux for the POV-RAY raytracer (with wxpython GUI).

When the user clicks on render I use 'kstart --ontop povray ...' to launch the render on top. The problem is that I need to know the PID of povray to read the output.

I get the PID of kstart ( that dies when povray is started ), but I do not get the child PID.

Does anyone have an idea ?


Thanks
fabien
remove _nospam_ to answer

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

2

Wednesday, June 8th 2005, 3:19pm

Maybe running a script and having it write the PID to some temporary file or a pipe.

Cheers,
_
Qt/KDE Developer
Debian User

3

Wednesday, June 8th 2005, 10:54pm

Yes but how do you get the PID number of the app launched by kstart ?
fabien
remove _nospam_ to answer

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

4

Thursday, June 9th 2005, 10:47am

When writing the PID of the real program into a file inside the script, the PID of the script doesn't matter, does it?

Cheers,
_
Qt/KDE Developer
Debian User

5

Thursday, June 9th 2005, 12:26pm

with the python script below :

f=popen2.Popen4('kstart --ontop povray +itest.pov',1)
az=f.pid

az returns the PID number of kstart, not the PID NUMBER of povray


whereas with
f=popen2.Popen4('povray +itest.pov',1)
az=f.pid

az returns the PID number of povray.

I need to know the PID number to check whether the render is still running and to read the output stream.

Thanks
fabien
remove _nospam_ to answer

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

6

Thursday, June 9th 2005, 3:16pm

So are you ignoring my initial suggestion or did I just not get through that you ought to start a script instead of povray and have the script write the PID into a file or PIPE?

Cheers,
_
Qt/KDE Developer
Debian User

7

Thursday, June 9th 2005, 7:00pm

Sorry, but I do not understand ( back from work, dumbness overwhelms me)...

What do you suggest ?
Sure, I can use a script that writes the child PID into a pipe, but I just do not know how to retrieve it.

with this command...
f=popen2.Popen4('kstart --ontop povray +itest.pov',1)

kstart spawns a child, but I cannot get the PID of its child.


If you have even a tiny script, please enclose it.

Thanks for enduring this.

Fabien
fabien
remove _nospam_ to answer

jacek

Trainee

Posts: 105

Location: Warsaw, Poland

Occupation: Student

  • Send private message

8

Thursday, June 9th 2005, 7:29pm

Quoted

Originally posted by fabienhenon
with this command...
f=popen2.Popen4('kstart --ontop povray +itest.pov',1)

f.pid ?

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

9

Thursday, June 9th 2005, 9:07pm

Quoted

Originally posted by fabienhenon
What do you suggest ?
Sure, I can use a script that writes the child PID into a pipe, but I just do not know how to retrieve it.


By reading the file/pipe?

For example in bash you can do this

Source code

1
2
povray $@ &
echo $! > $(kdeconfig --path tmp)/povray.pid


Then read povray.pid from the KDE tmp location
I guess an advanced script language like Python can do this as well.

Cheers,
_
Qt/KDE Developer
Debian User

10

Friday, June 10th 2005, 5:27pm

Hi,

With the script below :
povray $@ &
echo $! > $(kdeconfig --path tmp)/povray.pid

I can get povray pid



With the script below :
kstart povray $@ &
echo $! > $(kdeconfig --path tmp)/povray.pid

I can get kstart pid, not povray pid (and that is what I want)


Cheers,
Fabien
fabien
remove _nospam_ to answer

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

11

Saturday, June 11th 2005, 1:10pm

Quoted

Originally posted by fabienhenon
With the script below :
kstart povray $@ &
echo $! > $(kdeconfig --path tmp)/povray.pid

I can get kstart pid, not povray pid (and that is what I want)


Obviously, as you again use povray as the command for kstart instead of the script.

Do you think creating a script and putting it somewhere help when you don't change the command you are calling?

Cheers,
_
Qt/KDE Developer
Debian User