[ale] Re: perl new IPC::Semaphore and/or C semget()
Geoffrey
esoteric at 3times25.net
Wed Jun 23 13:06:09 EDT 2004
Geoffrey wrote:
> I've done quite a bit of work with SysV ipcs, and some with perl. I
> can't recall, or locate the answer to a question that's bugging me.
>
> When using new IPC::Semaphore() semget() or semget(2), is the process of
> getting the semaphore atomic? Assuming usage as in:
>
> my $sem = new IPC::Semaphore($semkey, 1, IPC_EXCL | IPC_CREAT | 0666);
>
> or similar use of semget(2) in C?
>
> The point is, does anyone see the flaw in using exclusive creation of a
> semaphore as the semaphore?
It appears that it is atomic as the man page for semget states:
The presence in semflg of the fields IPC_CREAT and
IPC_EXCL plays the same role, with respect to the exis?
tence of the semaphore set, as the presence of O_CREAT and
O_EXCL in the mode argument of the open(2) system call:
i.e. the semget function fails if semflg asserts both
IPC_CREAT and IPC_EXCL and a semaphore set already exists
for key.
Don't know how I missed that.
--
Until later, Geoffrey Registered Linux User #108567
Building secure systems in spite of Microsoft
More information about the Ale
mailing list