Re: Creatng 100% separate process from Parent
- From: "James Brown" <dont_bother>
- Date: Sat, 26 Nov 2005 09:53:29 -0000
There's not really any concept of "parent/child" processes in Windows -
The way process-explorer works is to look at each process in the system and
check the pid of the process that started it. It then builds a "best guess"
hierarchy using
this information. But such a hierarchy is not maintained by Windows itself.
Of course it is convenient for us to refer to processes as "parent" and
"child" because
it makes explaining things simpler.
Note that a "parent" process could terminate whilst the "child" process is
still
executing. However, the "child" process still maintains its
"parent-process-pid".
So another process could start with the same pid as the "parent" - should
this now
be referred to as the the parent of this child process?? Of course not.
ProcessExplorer presumably deals with this scenario by also looking
at the process-creation time stamps as it builds it's tree.
I have a small program on my website (with source) which shows how to build
the same process-hierarchy that ProcessExplorer uses:
www.catch22.net/source/
Back to the original problem :
To make an "independent" child process, make it respawn itself as soon as it
starts
(with a special "flag" at the commandline so that it doesn't do the same) -
and then exit the first child process, leaving an "orphaned" copy of itself.
This
secondary child process's parent-pid will be set to the first child's pid
(which
has exited), and will show up in ProcessExplorer as a "root" process as it
effectively has no parent.
James
--
www.catch22.net
Free win32 software, sourcecode and tutorials
"Hector Santos" <nospamhere@xxxxxxxxxxxxxx> wrote in message
news:%239xqLah8FHA.2616@xxxxxxxxxxxxxxxxxxxxxxx
> I'm trying to create a process that is independent of the parent with
> CreateProcess().
>
> By independent, when using Process Explorer from sysinternals.com, I don't
> want the spawned process to be a "child" under the parent process.
>
> I tried various CreateProcess flags, include CREATE_NEW_PROCESS_GROUP.
>
> When run separately (manually), of course, Process Explorer shows it as a
> independent process (as part of the EXPLORER.EXE process).
>
> The reason I want this is because the main process is traditionally an
> independent RPC server process and the second RPC client process (a
> configuration tool) is typically just run from the start menu.
>
> I added a "Run Configuration" to the server process tray menu and I don't
> want any hidden new unforeseen issues by given the user a "convenience"
> menu
> option.
>
> Thanks in advance
>
> ---
> Hector Santos
>
.
- Follow-Ups:
- Re: Creatng 100% separate process from Parent
- From: Hector Santos
- Re: Creatng 100% separate process from Parent
- From: Hector Santos
- Re: Creatng 100% separate process from Parent
- References:
- Creatng 100% separate process from Parent
- From: Hector Santos
- Creatng 100% separate process from Parent
- Prev by Date: Re: Creatng 100% separate process from Parent
- Next by Date: Re: Creatng 100% separate process from Parent
- Previous by thread: Re: Creatng 100% separate process from Parent
- Next by thread: Re: Creatng 100% separate process from Parent
- Index(es):
Relevant Pages
|