By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,939 Members | 1,600 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,939 IT Pros & Developers. It's quick & easy.

Killing a dependant process

P: n/a
There is a process A that launches process B as a COM object.
If the User tries to end process A, process B should also end. But vice
versa is not true. Process A can run independant of process. It is not
possible for a user to know process B is launched by process A.
In the destructor of Process A, there is a code to close process B. During
normal closing of process A, process B also gets closed. In certain
situations this is not happening-

1. When I clsoe process A from task manager, process B is still running. How
to close process B in this situation from code?
2. If process A has launched Process B, and process A has crashed, it still
leaves process B running.

This is a situation I would like to avoid. How is it possible to handle
these scenarios?

Oct 29 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
It's possible to kill a process in such a way
that it's "desctructor" code won't be executed.
When a process crashes, it's "desctructor code" often is not run as well.
Think of another solution, not depending on "desctructor" code in process A.

Regards,
--PA
Sraj wrote:
There is a process A that launches process B as a COM object.
If the User tries to end process A, process B should also end. But vice
versa is not true. Process A can run independant of process. It is not
possible for a user to know process B is launched by process A.
In the destructor of Process A, there is a code to close process B. During
normal closing of process A, process B also gets closed. In certain
situations this is not happening-

1. When I clsoe process A from task manager, process B is still running. How
to close process B in this situation from code?
2. If process A has launched Process B, and process A has crashed, it still
leaves process B running.

This is a situation I would like to avoid. How is it possible to handle
these scenarios?
Oct 29 '08 #2

P: n/a
Thanks Pavel for your suggestion. The whole idea of my question is - where
else should I write the code? Any idea what happens internally during crash?
Which part of the code is being called to shut down process A? If that
information is known then code can e written accordingly.

"Pavel A." wrote:
It's possible to kill a process in such a way
that it's "desctructor" code won't be executed.
When a process crashes, it's "desctructor code" often is not run as well.
Think of another solution, not depending on "desctructor" code in process A.

Regards,
--PA
Sraj wrote:
There is a process A that launches process B as a COM object.
If the User tries to end process A, process B should also end. But vice
versa is not true. Process A can run independant of process. It is not
possible for a user to know process B is launched by process A.
In the destructor of Process A, there is a code to close process B. During
normal closing of process A, process B also gets closed. In certain
situations this is not happening-

1. When I clsoe process A from task manager, process B is still running. How
to close process B in this situation from code?
2. If process A has launched Process B, and process A has crashed, it still
leaves process B running.

This is a situation I would like to avoid. How is it possible to handle
these scenarios?
Oct 29 '08 #3

P: n/a
Sraj wrote:
Thanks Pavel for your suggestion. The whole idea of my question is - where
else should I write the code? Any idea what happens internally during crash?
Which part of the code is being called to shut down process A? If that
information is known then code can e written accordingly.
The code that shuts down a crashed or killed process
is the OS... Would you hack the kernel to accomplish your goal?
Maybe, instead, make the process B cooperate ?

--PA

"Pavel A." wrote:
>It's possible to kill a process in such a way
that it's "desctructor" code won't be executed.
When a process crashes, it's "desctructor code" often is not run as well.
Think of another solution, not depending on "desctructor" code in process A.

Regards,
--PA
Sraj wrote:
>>There is a process A that launches process B as a COM object.
If the User tries to end process A, process B should also end. But vice
versa is not true. Process A can run independant of process. It is not
possible for a user to know process B is launched by process A.
In the destructor of Process A, there is a code to close process B. During
normal closing of process A, process B also gets closed. In certain
situations this is not happening-

1. When I clsoe process A from task manager, process B is still running. How
to close process B in this situation from code?
2. If process A has launched Process B, and process A has crashed, it still
leaves process B running.

This is a situation I would like to avoid. How is it possible to handle
these scenarios?
Oct 29 '08 #4

P: n/a


"Sraj" <Sr**@discussions.microsoft.comwrote in message
news:F2**********************************@microsof t.com...
There is a process A that launches process B as a COM object.
If the User tries to end process A, process B should also end. But vice
versa is not true. Process A can run independant of process. It is not
possible for a user to know process B is launched by process A.
In the destructor of Process A, there is a code to close process B. During
normal closing of process A, process B also gets closed. In certain
situations this is not happening-

1. When I clsoe process A from task manager, process B is still running.
How
to close process B in this situation from code?
2. If process A has launched Process B, and process A has crashed, it
still
leaves process B running.

This is a situation I would like to avoid. How is it possible to handle
these scenarios?
Is the code for both process A and process B under your control?

If yes, then set an environment variable when starting process B. Process B
will look for that and then watch (using WaitForSingleObject or one of its
kin) for process A to quit and then end itself.
>
Oct 31 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.