IPC and counters
Paul Makepeace
paulm at paulm.com
Thu Oct 16 08:47:29 BST 2008
On Thu, Oct 16, 2008 at 7:36 AM, Philip Newton <philip.newton at gmail.com> wrote:
> On Wed, Oct 15, 2008 at 02:01, Simon Wistow <simon at thegestalt.org> wrote:
>> Child:
>>
>> my ($msg, $sem_id) = get_message();
>> my $sem = IPC::Semaphore->new($sem_id);
>> if (0 == $sem->op(0, -1, IPC_NOWAIT)) {
>> do_something($message);
>> }
>>
>> # If we're the last then clean up
>> if (EAGAIN == $sem->op(1,-1, IPC_NOWAIT)) {
>> $sem->remove;
>> }
>
> Does the module really export no constants for this "0, 1, -1" stuff?
The first arg is the semaphore number, the second is what to do with
it: acquire (-1)/release (+1) the semaphore or wait for it to be full
(0).
http://www.linuxhq.com/guides/LPG/node52.html
> It all seems rather error-prone to me.
>
> Cheers,
> --
> Philip Newton <philip.newton at gmail.com>
>
More information about the london.pm
mailing list