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

Re: [HACKERS] [PATCHES] fork/exec patch

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>,pgsql-hackers-win32 <pgsql-hackers-win32(at)postgresql(dot)org>
Subject: Re: [HACKERS] [PATCHES] fork/exec patch
Date: 2003-12-15 21:21:07
Message-ID: 200312152121.hBFLL7f16251@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-hackers-win32pgsql-patches
Andrew Dunstan wrote:
> Bruce Momjian wrote:
> 
> >Have you looked at the CONNX signal code on the Win32 page:
> >
> >	http://momjian.postgresql.org/main/writings/pgsql/win32.html
> >
> >It uses shared memory and events.
> >
> >  
> >
> 
> Yes, and I just did again. I guess I must be missing something, though - 
> I don't see what in that code causes the signalled process to call the 
> handler corresponding to the signal. Maybe I'm just a little brain dead 
> today ...

In the CONNX code for kill() I see:

    sprintf(szEventName, "CONNX_SIGNAL_%x", (int) lPID);
    sprintf(szSharedMemoryName, "CONNX_SMEM_%x", (int) lPID);
    hSharedMemory = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, szSharedMemoryName);
    if (hSharedMemory) {
        /* Call the signal handle for that process.. */
        void           *pData = MapViewOfFile(hSharedMemory, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(int));
        if (pData) {
            int             nReturn;
            HANDLE          hProcessHandle;
            DWORD           ExitCode;
            *(int *) pData = nSignal;
            UnmapViewOfFile(pData);
            /* Open the event handle of the other process */
            hEvent = OpenEvent(EVENT_MODIFY_STATE | SYNCHRONIZE, FALSE, szEventName);
            hProcessHandle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, lPID);
            if (hEvent) {
                SetEvent(hEvent);
                /* Wait for Event to be processed. */
                do {
                    nReturn = WaitForSingleObject(hEvent, 0);

Now, I am no Win32 programmer, but the mixture of OpenFileMapping() and
OpenEvent() looked promising.  :-)


-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

In response to

pgsql-hackers by date

Next:From: Tom LaneDate: 2003-12-15 21:26:36
Subject: 7.4.1 release status
Previous:From: Andrew DunstanDate: 2003-12-15 21:12:13
Subject: Re: [HACKERS] [PATCHES] fork/exec patch

pgsql-patches by date

Next:From: Bruce MomjianDate: 2003-12-15 23:30:09
Subject: Re: ISO 8601 "Time Intervals" of the "format with time-unit
Previous:From: Andrew DunstanDate: 2003-12-15 21:12:13
Subject: Re: [HACKERS] [PATCHES] fork/exec patch

pgsql-hackers-win32 by date

Next:From: Merlin MoncureDate: 2003-12-15 21:28:34
Subject: Re: [PATCHES] fork/exec patch
Previous:From: Andrew DunstanDate: 2003-12-15 21:12:13
Subject: Re: [HACKERS] [PATCHES] fork/exec patch

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group