开发者

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);    
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜