dsoprea / PyInotify

An efficient and elegant inotify (Linux filesystem activity monitor) library for Python. Python 2 and 3 compatible.
GNU General Public License v2.0
246 stars 74 forks source link

errno is always 0 #14

Closed flolf closed 6 years ago

flolf commented 8 years ago

Hello there,

While using PyInotify I've noticed that the ERRNO value returned by InotifyError is always equal to zero:

In [1]: import os

In [2]: path = "/foo"

In [3]: os.path.exists(path)
Out[3]: False

In [4]: import inotify.adapters

In [5]: i = inotify.adapters.Inotify()

In [6]: i.add_watch(path)
---------------------------------------------------------------------------
InotifyError                              Traceback (most recent call last)
<ipython-input-6-5bee764f928e> in <module>()
----> 1 i.add_watch(path)

/home/florent/.local/lib/python2.7/site-packages/inotify/adapters.pyc in add_watch(self, path, mask)
     65         _LOGGER.debug("Adding watch: [%s]", path)
     66
---> 67         wd = inotify.calls.inotify_add_watch(self.__inotify_fd, path, mask)
     68         _LOGGER.debug("Added watch (%d): [%s]", wd, path)
     69

/home/florent/.local/lib/python2.7/site-packages/inotify/calls.pyc in _check_nonnegative(result)
     33     if result == -1:
     34         raise InotifyError("Call failed (should not be -1): (%d)" %
---> 35                            (result,))
     36
     37     return result

InotifyError: Call failed (should not be -1): (-1) ERRNO=(0)    

In this specific case I would expect ERRNO to be equal to ENOENT.

I am using python 2.7 and Jessie:

[21:11:00 :~]$ python --version
Python 2.7.9
[21:11:02 :~]$  cat /etc/debian_version
8.2
linuxoid69 commented 7 years ago

why it occurs?

dsoprea commented 6 years ago

Closing this. I'm relying on the library to set these if relevant. It's either not set in this case or not set by inotify ever.