emcrisostomo / fswatch

A cross-platform file change monitor with multiple backends: Apple OS X File System Events, *BSD kqueue, Solaris/Illumos File Events Notification, Linux inotify, Microsoft Windows and a stat()-based backend.
https://emcrisostomo.github.io/fswatch/
GNU General Public License v3.0
4.98k stars 327 forks source link

inotify_rm_watch: Invalid argument #206

Open JacobAMason opened 6 years ago

JacobAMason commented 6 years ago

I tried to test out fswatch with the following simple command:

fswatch -0 test | xargs -0 -n1 echo "Hello"

After each response

Hello /home/JacobAMason/test

I get the following

inotify_rm_watch: Invalid argument
Hello

This happens on every update to the file. So I have this output:

fswatch -0 test | xargs -0 -n1 echo "Hello"
Hello /home/JacobAMason/test
inotify_rm_watch: Invalid argument
Hello
Hello /home/JacobAMason/test
inotify_rm_watch: Invalid argument
Hello
Hello /home/JacobAMason/test
inotify_rm_watch: Invalid argument
Hello
...

Any idea what could cause this? I'm running fswatch 1.11.2 on Archlinux.

emcrisostomo commented 6 years ago

Hi @JacobAMason, thanks for the report. I'll have to investigate it. Could you dump the directory structure of the test directory and all its contents and attach them to this issue?

$ find test -type d > directories.txt
$ find test > contents.txt
SpaceKatt commented 6 years ago

I also just ran into this issue, while using fswatch on a rasPi.

My workaround was to switch the monitor that I was using:

fswatch -m poll_monitor

You can find the list of available monitors by using the -M flag:

pi@raspberrypi:~/csound/hello_world $ fswatch -M
  inotify_monitor
  poll_monitor
pi@raspberrypi:

Here is my output when I do not switch monitors:

pi@raspberrypi:~/csound/hello_world $ fswatch -0 pluck.csd
/home/pi/csound/hello_world/pluck.csdinotify_rm_watch: Invalid argument

Here is my output when I do switch monitors:

pi@raspberrypi:~/csound/hello_world $ fswatch -m poll_monitor -0 pluck.csd
/home/pi/csound/hello_world/pluck.csd
emcrisostomo commented 5 years ago

Closing this because there's no way to replicate this issue and there's no feedback from the issuer.

Jammmmm commented 5 years ago

Sorry to reopen this, but I can confirm that this is an issue:

I run fswatch with _inotifymonitor and then modify index.php:

*fswatch -m inotify_monitor -t -x /path/.php**

    Mon 04 Feb 2019 09:56:32 PM UTC /path/index.php Updated
    inotify_rm_watch: Invalid argument
    Mon 04 Feb 2019 09:56:33 PM UTC  AttributeModified

I run fswatch with _pollmonitor and then modify index.php and it stops happening:

*fswatch -m poll_monitor -t -x /path/.php**

    Mon 04 Feb 2019 09:57:50 PM UTC /path/index.php Updated AttributeModified

To confirm it's not something to do with my command line, I removed everything (so it should default to inotify_monitor) and it happens again:

*fswatch /path/.php**

    /path/index.php
    inotify_rm_watch: Invalid argument

As for index.php, it's a regular file. Nothing special about it, or the path:

-rw-rw-r--+ 1 root        root          26 Feb  4 22:02 index.php
stacyharper commented 5 years ago

I'm facing the same issue.

fswatch -0 **/*.php | while read -d "" event; do echo ${event}; done
/home/eddie/Workspace/COMPANY/projects/PROJECT/app/FILEPATH/FILENAME.php
inotify_rm_watch: Invalid argument
$ fswatch --version
fswatch 1.11.2
Copyright (C) 2013-2017 Enrico M. Crisostomo <enrico.m.crisostomo@gmail.com>.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Enrico M. Crisostomo.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:        18.04
Codename:       bionic

$ uname -r
4.15.0-45-generic
emcrisostomo commented 5 years ago

I thought it was something related with file names but according to @Jammmmm that's not the case. Would anyone attach a zipped directory I can use to replicate this problem? I haven't been able to replicate it and until I do there's no way I can fix it.

Jammmmm commented 5 years ago

Attached: test.zip

There's nothing special about it. Standard directory with standard file.

I've tried running fswatch as a regular user and as root. Both have the problem.

I have just noticed that @Eluminae is using Ubuntu. I am too. Maybe that has something to do with it?

lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.5 LTS
Release:        16.04
Codename:       xenial

uname -r 4.4.0-141-generic

fswatch --version

fswatch 1.14.0
Copyright (C) 2013-2018 Enrico M. Crisostomo <enrico.m.crisostomo@gmail.com>.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Enrico M. Crisostomo.
sersorrel commented 5 years ago

I'm also observing this issue on Ubuntu 18.04, fswatch 1.11.2.

vrajanap commented 5 years ago

Also observing this on Ubuntu 18.10 and fswatch 1.12.0

vrajanap commented 5 years ago

Checked out sources with version 1.13.0 and locally built it. That seems to work fine.

stacyharper commented 5 years ago

I got the same thing on archlinux, sadly.

$ fswatch --version

fswatch 1.14.0

Copyright (C) 2013-2018 Enrico M. Crisostomo <enrico.m.crisostomo@gmail.com>.

License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.

This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law.

Written by Enrico M. Crisostomo.
$ uname -r

5.0.2-arch1-1-ARCH
yhaiovyi commented 4 years ago

Same here, on rpi3b+

mxork commented 2 years ago

Ditto. Seem to only get the output on renames of the watched file. There's only two calls to inotify_rm_watch in inotify_monitor.cpp so it shouldn't be too hard to figure out what is happening. Will try to make a patch when I have a chance.

Replication:

#!/bin/bash

fswatch -x X &

echo "creating"
touch X
sleep 2

echo "touching"
touch X
sleep 2

echo "moving"
mv X Y
mv Y X
sleep 2

echo "writing"
echo "X" > X
sleep 2

echo "modify write attr"
chmod -w X
sleep 2

echo "modify write attr (revert)"
chmod +w X
sleep 2

echo "deleting"
rm X
sleep 2

kill %1

Output:

creating
touching
/tmp/tmp.nuBGl9PTsZ/X PlatformSpecific
/tmp/tmp.nuBGl9PTsZ/X AttributeModified
/tmp/tmp.nuBGl9PTsZ/X Updated
moving
/tmp/tmp.nuBGl9PTsZ/X Updated
 Updated
inotify_rm_watch: Invalid argument
writing
/tmp/tmp.nuBGl9PTsZ/X Updated
/tmp/tmp.nuBGl9PTsZ/X PlatformSpecific
/tmp/tmp.nuBGl9PTsZ/X Updated
/tmp/tmp.nuBGl9PTsZ/X Updated
modify write attr
/tmp/tmp.nuBGl9PTsZ/X AttributeModified
modify write attr (revert)
/tmp/tmp.nuBGl9PTsZ/X AttributeModified
deleting
/tmp/tmp.nuBGl9PTsZ/X AttributeModified

Archlinux: 5.13.13-arch1-1 fswatch: 1.16.0-develop, built from 6afad282