Global named event equivalent in Unix
What is the global named event object equivalent in Unix? I need to create a named event-like object in unix so that another process can set it
pseudocode in Win32:
HANDLE hEvent=CreateEvent(...,"Global\\CSAPP");
while(1)
{
WaitForSingleObject(hEvent);
...
}
In开发者_如何学C another process:
HANDLE hEvent=OpenEvent(...,"Global\\CSAPP");
SetEvent(hEvent);
You are probably looking for a named semaphore.
int initial = 0;
sem_t *sem = sem_open("/global_name", O_CREAT, 0644, initial);
/* Down ("Wait"). */
sem_wait(sem);
/* Up ("Set") . */
sem_post(sem);
精彩评论