Re: [pgsql-hackers-win32] [PATCHES] fork/exec patch - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [pgsql-hackers-win32] [PATCHES] fork/exec patch
Date
Msg-id 200312152121.hBFLL7f16251@candle.pha.pa.us
Whole thread Raw
In response to Re: [PATCHES] fork/exec patch  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
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@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: 7.4.1 release status
Next
From: Devrim GUNDUZ
Date:
Subject: Re: Locale-based identifier conversion and Turkish