🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
3 messages
3 total messages Started by Juan Diego Garc�s Thu, 15 May 2003 13:44
Kill a process
#16410
Author: Juan Diego Garc�s
Date: Thu, 15 May 2003 13:44
10 lines
1174 bytes
I have two three application. The first one launches a process (with the
CreateProcess API) called X, and from the second I have to stop this
process.

I found the TerminateProcess API, but the first parameter is the andle to
the process. Is there an API to get this handle?

Thanks

Juan Diego Garc�s
Re: Kill a process
#16412
Author: Vladimir Afanasyev
Date: Thu, 15 May 2003 14:34
36 lines
2087 bytes
Hi,

"Juan Diego Garc�s" <jgarces@amics.ch> wrote:
>I have two three application. The first one launches a process (with the
>CreateProcess API) called X, and from the second I have to stop this
>process.
>
>I found the TerminateProcess API, but the first parameter is the andle to
>the process. Is there an API to get this handle?
>
>Thanks
>
>Juan Diego Garc�s
>
>

To use TerminateProcess you need to use OpenProcess before.
The result of OpenProcess it is handle that you need.
To use OpenProcess you need to know ProcessId.

First process know ProcessId because it uses CreateProcess 
function (result - PROCESS_INFORMATION structure).

So the task of first process pass ProcessId to second 
process via file, pipe, etc.

The only problem that "TerminateProcess function is 
used to unconditionally cause a process to exit".
TerminateProcess do not it work clear - some dlls 
can be stay yet in memory after process termination.

Some additional problems can be for Win NT/2000/XP 
(access rights).

Vladimir.
Re: Kill a process
#16419
Author: Remy Lebeau (TeamB)
Date: Thu, 15 May 2003 16:39
16 lines
1576 bytes
"Juan Diego Garc�s" <jgarces@amics.ch> wrote in message
news:3ec399e6@newsgroups.borland.com...
> I have two three application. The first one launches
> a process (with the CreateProcess API) called X,
> and from the second I have to stop this process.

Why not just have the first process terminate itself after starting the
second?  CreateProcess() is not a blocking function.  What exactly are you
trying to accomplish?  TerminateProcess() is a brute-force approach, it
should be avoided whenever possible as it does not allow the terminating
process to perform any kind of cleanup on itself, thus the potential to leak
a lot of resources.


Gambit
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