#include #include #define CYGWIN_IPCNT_SEMSEM "MultiSemSem_" #define GLOBAL_CYGWIN_IPCNT_SEMSEM "Global\\MultiSemSem_" int main(int argc, char* argv[]) { HANDLE handle = 0; char* semaphore = CYGWIN_IPCNT_SEMSEM; if (argc > 1 && argv[1][0] == '1') semaphore = GLOBAL_CYGWIN_IPCNT_SEMSEM; handle = OpenSemaphore(SEMAPHORE_ALL_ACCESS, FALSE, semaphore); if (handle) { printf("%ld = OpenSemaphore(%s) succeeded\n", handle, semaphore); CloseHandle(handle); } else { printf("OpenSemaphore(%s) failed with last error = %ld\n", semaphore, GetLastError()); } return 0; }