Re: Win32 question: getppid() with no parent? - Mailing list pgsql-hackers-win32

From Magnus Hagander
Subject Re: Win32 question: getppid() with no parent?
Date
Msg-id 6BCB9D8A16AC4241919521715F4D8BCE1716A5@algol.sollentuna.se
Whole thread Raw
In response to Win32 question: getppid() with no parent?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Win32 question: getppid() with no parent?
List pgsql-hackers-win32
>> Question though - we keep a PostmasterPid variable, right?
>
>Yeah we do; we must have it to signal the postmaster from the children.
>
>> (If we can't rely on that variable, we could do a win32 specific hack
>> that passes the HANDLE of the postmaster down to the child on exec, I
>> guess.)
>
>Is this just like passing a variable value, or is there some more
>protection involved?

It is passing a variable. *Before* you parse it, you have to make it
inheritable by doing something along the line of:
DuplicateHandle(GetCurrentProcess(), GetCurrentProcess(),
GetCurrentProcess(), &targetHandle, 0, TRUE, DUPLICATE_SAME_ACCESS);

(If you just do GetCurrentProcess() it will return a hard-coded
pseudohandle. So if you use that handle in the child process, it will
point to the child process. DuplicateHandle will turn it into a real
handle)

//Magnus

pgsql-hackers-win32 by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Win32 question: getppid() with no parent?
Next
From: "Magnus Hagander"
Date:
Subject: Re: Primary Key results in endless loop