[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: inotify ffi

From: Mark H Weaver
Subject: Re: inotify ffi
Date: Tue, 11 Nov 2014 14:10:35 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Chaos Eternal <address@hidden> writes:
> i wrote a FFI to inotify system call.
> procedures:
> * inotify-init
> * inotify-init1
> * inotify-add-watch
> * inotify-rm-watch
> * inotify-read-port
> the errno handle is unreliable, use with caution.
> License: LGPL v3

and later, he wrote:
> and it is not very portable.

Thanks for working on this, but as you pointed out, the method you use
to check 'errno' is extremely unportable and also quite fragile.  It
makes assumptions about internal details of the C library and Guile, and
is likely to break in future versions of glibc and/or Guile.

It might not even work properly with current versions.  There are many
things that could happen between the call to the C function and checking
'errno' that might disturb the value of 'errno'.

Unfortunately, there's currently no proper way to check 'errno' using
the Dynamic FFI.  For now, the only proper solution is to write a C
extension as described in:

Your C wrapper should call the relevant C function and then immediately
read the value of 'errno' if the return value indicates an error.  You
should not make any calls to libguile before reading 'errno'.

Hopefully, Guile 2.0.12 will include a way to check 'errno' after calls
to the Dynamic FFI.  Most likely, this will involve adding a keyword
argument to 'pointer->procedure' that causes the generated wrapper to
check 'errno' immediately after the C function returns.  The ticket for
this issue is here:


reply via email to

[Prev in Thread] Current Thread [Next in Thread]