You are not logged in.

#1 2011-03-24 11:06:48

metre
Member
Registered: 2011-03-13
Posts: 130

[SOLVED] Bash: pkill a process after exiting from another one?

Hi there, I use a program which calls another one, but when I close the first one, the second one is not closed automatically even if not anymore needed, so I have to do it manually.

I tried a classic:

firstprogram
pkill secondprogram

but, of course, this script closes immediately the secondprogram.
So, what I supposed to do?
Thank you in advance!

Last edited by metre (2011-03-24 11:33:01)

Offline

#2 2011-03-24 11:15:25

hbekel
Member
Registered: 2008-10-04
Posts: 311

Re: [SOLVED] Bash: pkill a process after exiting from another one?

Hard to tell unless you show us some code or at least mention the method used to launch the subprocess. Generally you should wait(3) for your child processes to exit before exiting your parent process, or terminate the child manually when the parent exits, e.g decide yourself when it is "not needed anymore".

Last edited by hbekel (2011-03-24 11:16:11)

Offline

#3 2011-03-24 11:32:42

metre
Member
Registered: 2011-03-13
Posts: 130

Re: [SOLVED] Bash: pkill a process after exiting from another one?

hbekel wrote:

Hard to tell unless you show us some code or at least mention the method used to launch the subprocess. Generally you should wait(3) for your child processes to exit before exiting your parent process, or terminate the child manually when the parent exits, e.g decide yourself when it is "not needed anymore".

thank you, I did it:

firstprogram
wait
pkill secondprogram

it works, woah

Offline

Board footer

Powered by FluxBB