Re: 8.3 .4 + Vista + MingW + initdb = ACCESS_DENIED

Поиск
Список
Период
Сортировка
От Andrew Chernow
Тема Re: 8.3 .4 + Vista + MingW + initdb = ACCESS_DENIED
Дата
Msg-id 48F89D52.5010002@esilo.com
обсуждение исходный текст
Ответ на Re: 8.3 .4 + Vista + MingW + initdb = ACCESS_DENIED  (Andrew Dunstan <andrew@dunslane.net>)
Ответы Re: 8.3 .4 + Vista + MingW + initdb = ACCESS_DENIED  (Andrew Dunstan <andrew@dunslane.net>)
Список pgsql-hackers
Andrew Dunstan wrote:
>>
>> Has anyone considered not using a file lock on windows?  CreateMutex 
>> might do the trick if provided a mutex name, making it global rather 
>> than process bound.  OpenMutex can be used to test if the mutex exists 
>> or if it is currently locked.  I guess it would stay locked.  If there 
>> is a crash, it is automatically closed by the os.
>>
>> The docs state the system closes the handle (mutex) when the process 
>> terminates and makes no mention of this being a lingering action like 
>> LockFileEx.  It sounds like the mutex is closed ASAP when the process 
>> terminates, just like file handles.
>>
> 
> Please review the previous discussion. This whole thing came about 
> because of major problems in handling Global objects.
> 
> cheers
> 
> andrew
> 
> 

I did review it which is why I proposed global mutexes.  No one spoke 
about mutexes.  The conversation was about global sections, like file 
mappings.  Global sections fall under a stricter security policy than 
global mutexes.  I just ran the below code on Vista as a dumb-dumb 
non-administrative user (no SeCreateGlobalPrivilege) and it worked like 
a charm (compiled with VisualStudio.NET 2003 v7 13.10.3077).  Maybe I am 
missing something?

// run the below from different consoles.  the first run will
// create the mutex and sleep for 10 seconds before destroying it.
// The other console will open the existing mutex.
#include <windows.h>
#include <stdio.h>

int main(int argc, char **argv)
{  HANDLE h = CreateMutex(NULL, TRUE, "Global\\__postmaster__");
  if(h == NULL)  {    printf("CreateMutex: %u\n", GetLastError());    return 1;  }
  if(GetLastError() == ERROR_ALREADY_EXISTS)  {    printf("postmaster is running\n");  }  else  {    printf("postmaster
mutexcreated and ownership aquired\n");    Sleep(10000);  }
 
  CloseHandle(h);  return 0;
}

-- 
Andrew Chernow
eSilo, LLC
every bit counts
http://www.esilo.com/


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Cross-column statistics revisited
Следующее
От: Simon Riggs
Дата:
Сообщение: Hot Standby: First integrated patch