Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fswatch reports files/directories that are being read (Linux/Ubuntu/inotify_monitor) #134

Open
denilsonsa opened this Issue Sep 15, 2016 · 6 comments

Comments

Projects
None yet
5 participants
@denilsonsa
Copy link

denilsonsa commented Sep 15, 2016

How to reproduce:

  1. Run fswatch . in one terminal (or `fswatch -m inotify_monitor).
  2. Open another terminal.
  3. Execute one of: ls the_directory_where_you_are or cat some_file_inside_the_directory

Results (output of -x option):

/home/foo/bar IsDir
/home/foo/bar PlatformSpecific

Expected results: Only modified files/directories should be changed. Reading a directory or a file should not have any impact.

@mfornasa

This comment has been minimized.

Copy link

mfornasa commented Sep 30, 2016

Seeing the same issue. Possible fix?

@denilsonsa

This comment has been minimized.

Copy link
Author

denilsonsa commented Oct 4, 2016

Quick and dirty workaround: use the following shell script wrapper.

#!/bin/sh
/full/path/to/fswatch -x "$@" | sed '
    s/ IsDir//
    s/ PlatformSpecific//
    /^[^ ]*$/d
    s/ [a-zA-Z]\+$//
'

This wrapper will not work if your files contain space characters.

@bombazook

This comment has been minimized.

Copy link

bombazook commented Sep 27, 2017

This issue also breaks fswatch -1 -m inotify_monitor behaviour

@denilsonsa

This comment has been minimized.

Copy link
Author

denilsonsa commented Jul 18, 2018

Slightly better wrapper script:

#!/bin/sh
/full/path/to/fswatch -x "$@" | sed '
    s/ IsDir//
    s/ PlatformSpecific//
    s/\( [A-Z][a-zA-Z]\+\)\+$/ XXX_KEEP_THIS_LINE_XXX/
    / XXX_KEEP_THIS_LINE_XXX$/!d
    s/ XXX_KEEP_THIS_LINE_XXX$//
'
@mareklauko

This comment has been minimized.

Copy link

mareklauko commented Aug 22, 2018

I highly recommend to use fswatch with 'poll monitor' on LINUX systems
fswatch -r -m poll_monitor /your/path
=> fast and reliable recursive scanning, takes not a lot of CPU (~5% , 4 cores, i5-2450M), but less than 10MB ram. I am scanning ~32.000 files in ~2800 sub-directories. It reacts on changes/updates in 0.1second.

Hope, it helps someone.

@sgbotsford

This comment has been minimized.

Copy link

sgbotsford commented Sep 7, 2018

FS watch is a general file system watcher. Given the nature of the events that the underlying system call does, reading a directory is an event.. fswatch has some capability for event filtering. Using it with -n (numeric flags) allows you to bitwise OR it to the flags of interest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.