Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: Win32 question: getppid() with no parent?


  • From: "Magnus Hagander" <mha(at)sollentuna(dot)net>
  • To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
  • Cc: "PgSql-Win32" <pgsql-hackers-win32(at)postgresql(dot)org>
  • Subject: Re: Win32 question: getppid() with no parent?
  • Date: Thu, 27 May 2004 20:32:28 +0200
  • Message-id: <6BCB9D8A16AC4241919521715F4D8BCE34BB4A(at)algol(dot)sollentuna(dot)se>

>>>> (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);
>
>But you'd do that only once during postmaster start, right?  It's
>probably marginally faster/safer to do that than to fabricate a new
>handle in each child based on PostmasterPid.

Yup, then you could just write the HANDLE vlaue (basically a 32-bit
integer) to the backend startup file and put it on the commandline to
pgstat.
If you need the pgstat process to keep track of it's chlid (the other
pgstat process), you'd need it once there too. Not sure if that's
needed.

And yes, I think it's marginally safer.

//Magnus



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group