Re: sem_open() returns ENOSPC
Re: sem_open() returns ENOSPC
- Subject: Re: sem_open() returns ENOSPC
- From: Alastair Houghton <email@hidden>
- Date: Sun, 18 Jul 2010 17:30:27 +0100
On 18 Jul 2010, at 12:18, Jonas Maebe wrote:
> On 15 Jul 2010, at 01:50, Norm Green wrote:
>
>> Well that might account for the problem. Since I need (but do not have) unnamed POSIX semaphores in Darwin, I generate a random name for each semaphore but unlink. Sounds like I need to find some way to allocate semaphores with a well known name and then unlink it before attempting to use the name again.
>
> The easiest way to solve this is to immediately call sem_unlink() after you've called sem_open(). The semaphore will remain in existence until you call sem_close(). Since all file descriptors are automatically closed when a process terminates (either normally or abnormally), this prevents all semaphore leaking (unless you'd be terminated between the sem_open() and sem_unlink(), but that's very unlikely).
*However*, if you do this, you can't then obtain the semaphore by name from another process, since the name has been unlinked (it works just like the filesystem in this regard).
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden