my $efd = Linux::Perl::eventfd->new(
        initval => 4,
        flags => [ 'NONBLOCK', 'CLOEXEC' ], #only on 2.6.27+

    #or, e.g., Linux::Perl::eventfd::x86_64

    my $fd = $efd->fileno();


    my $read = $efd->read();


This is an interface to the eventfd/eventfd2 system call. (eventfd2 is only called if the given parameters require it.)

This class inherits from Linux::Perl::Base::TimerEventFD.


CLASS->new( %OPTS )

%OPTS is:

  • initval - Optional, as described in the eventfd documentation. Defaults to 0.

  • flags - Optional, an array reference of any or all of: NONBLOCK, CLOEXEC, SEMAPHORE. See man 2 eventfd for more details.

    Note that, in conformity with Perl convention, this module honors the $^F variable, which in its default configuration causes CLOEXEC even if the flag is not given. To have a non-CLOEXEC eventfd instance, then, set $^F to a high enough value that the eventfd file descriptor will not be an “OS” filehandle, e.g.:

        my $eventfd = do {
            local $^F = 1000;

$val = OBJ->read()

Reads a value from the eventfd instance. Sets $! and returns undef on error.

OBJ->add( NUMBER )

Adds NUMBER to the counter. Returns undef and sets $! on failure.