Re: Listing System V Semaphores on Tiger
Re: Listing System V Semaphores on Tiger
- Subject: Re: Listing System V Semaphores on Tiger
- From: Terry Lambert <email@hidden>
- Date: Wed, 26 Mar 2008 10:17:28 -0700
Yes, ioctl works fine. You just have to know the I'd, which you can
not know from ipcs. There are plenty of Luther ways to know it
though. The most common is to use ftok() on a known file to generate
a key, which will deterministically generate the same key each time.
Typically, programs which expect to crash will attempt to remove their
resources (ignoring errors, if they do not exist) prior to allocating
them, so that they will always be successful allocating them. Use of
an ftok() key guarantees they will be trying to remove/create the
right key each time, and buys them a means of rendezvous with other
programs, which an also know the file name (typically, you pick the
binary that creates the semaphore set/message queue/shared segment, or
one of its well known data files).
Another method is "not crashing", of course, but if it's not your
program, that might not be under your control.
Absolute worst case, it's possible to write an suid root program and
grovel around in /dev/kmem to get the information, if you can't
remember what you told the kernel to use as a key when the semaphore
set was created. If you use that method, you are pretty much on your
own, since there's no way to do it portable that can be guaranteed to
work on arbitrary releases.
-- Terry
On Mar 26, 2008, at 6:31 AM, Ray Ruvinskiy <email@hidden> wrote:
Thanks Terry.
On Tiger, is there a way to clean up System V semaphores that may
have been left behind by processes that have gone away, possibly by
writing code?
Thanks,
Ray
On 25-Mar-08, at 4:35 PM, Terry Lambert wrote:
On Mar 25, 2008, at 6:40 AM, Ray Ruvinskiy wrote:
I seem to be unable to get a list of currently existing System V
semaphores on Tiger using the ipcs utility. The list is always
empty, whether or not I run the command as root. On Leopard,
however, ipcs works as expected.
Is this a known issue, or is there something I'm missing?
The kernel support for the ipcs code and the structure changes
necessary in the contract between kernel and user space was
considered to risky to put in Tiger, so Tiger does not support it.
-- Terry
_______________________________________________
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
_______________________________________________
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