🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
5 messages
5 total messages Started by peter Thu, 30 Mar 2006 19:17
Create Process and dying parents...
#3996
Author: peter
Date: Thu, 30 Mar 2006 19:17
6 lines
884 bytes
hi, 
if I use CreateProcess in process A to create process B, how can I
make sure B exits if A is shut down?

is this possible? thanks!
Re: Create Process and dying parents...
#3999
Author: Remy Lebeau (TeamB)
Date: Thu, 30 Mar 2006 22:15
18 lines
1508 bytes
"peter" <pnandrus@attglobal.net> wrote in message
news:442c3cf4$1@newsgroups.borland.com...

> if I use CreateProcess in process A to create process B, how
> can I make sure B exits if A is shut down?

That depends on whether A is being shut down gracefully or unexpectedly.

If gracefully, then A can simply notify B to shut itself down.  How you do
that depends on what B actually is.

If unexpectedly, then the only way I can think of right now is to have A
pass its process ID as a command line parameter when launching B, and then
have B periodically check if that ID is still running.


Gambit
Re: Create Process and dying parents...
#4008
Author: peter
Date: Fri, 31 Mar 2006 14:06
32 lines
1780 bytes

What's the easiest way to check if a certain process is still
alive once I have the process ID?

thanks for the info. i hadn't even thought of that simple a 
solution.... =)




"Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote:
>
>"peter" <pnandrus@attglobal.net> wrote in message
>news:442c3cf4$1@newsgroups.borland.com...
>
>> if I use CreateProcess in process A to create process B, how
>> can I make sure B exits if A is shut down?
>
>That depends on whether A is being shut down gracefully or unexpectedly.
>
>If gracefully, then A can simply notify B to shut itself down.  How you do
>that depends on what B actually is.
>
>If unexpectedly, then the only way I can think of right now is to have A
>pass its process ID as a command line parameter when launching B, and then
>have B periodically check if that ID is still running.
>
>
>Gambit
>
>
Re: Create Process and dying parents...
#4015
Author: Remy Lebeau (TeamB)
Date: Fri, 31 Mar 2006 19:03
15 lines
1459 bytes
"peter" <pnandrus@attglobal.net> wrote in message
news:442d4576$1@newsgroups.borland.com...

> What's the easiest way to check if a certain process is still
> alive once I have the process ID?

You have to enumerate through all of the running processes until you find
(or don't find) the ID.  Look at the following article for details:

    How To Enumerate Applications Using Win32 APIs
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;q175030


Gambit
Re: Create Process and dying parents...
#4016
Author: Eric Noel
Date: Fri, 31 Mar 2006 19:26
8 lines
1284 bytes
> What's the easiest way to check if a certain process is still
> alive once I have the process ID?

If you don't need win9x compatibility, then you could use 
OpenProcess(SYNCHRONIZE,false,ProcessID). Then you can use 
WaitForSingleObject to poll the state.

- Eric
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads