From: Rob McCool <robm@netscape.com>
Newsgroups: netscape.devs-nsapi
Subject: Re: Semaphores
Date: Wed, 28 Aug 1996 14:19:59 -0700

Marc Verboven wrote: > Ok, thanks. Sem_init works now; but at that point there's nothing yet > in /tmp. When I manually touch the filename, it also gets removed when > I do a sem_terminate. > I do this as the same user (nobody) as the server is running. > > Question : should the file be visible in /tmp after sem_init or after > a sem_grab ?

It's not visible, the server does an open() and then immediately calls unlink().

> Also, sem_grab always returns -1; sem_tgrab seems to works fine. Is > there anything special about sem_grab (except from the fact that it > should block) ?

Hmm, this is Solaris, right? Looking at the code, it guarantees that the lock happened but returns the wrong value. Because Solaris uses user-level threads, the code for sem_grab actually just uses sem_tgrab to poll periodically anyway. I'll file a bug about the incorrect return value.

--
Rob McCool, robm@netscape.com http://home.netscape.com/people/robm/
Stunt Programmer, Netscape Communications Corporation
It was working ten minutes ago, I swear...
Reproduced by permission of the author.