Giter Club home page Giter Club logo

Comments (5)

eradman avatar eradman commented on June 30, 2024 1

No problem! I see why you would want to do that.

If you'd like to build entr from source it can be easily patched. Something like this:

diff --git a/missing/kqueue_inotify.c b/missing/kqueue_inotify.c
index 7891dda..eaa5d2b 100644
--- a/missing/kqueue_inotify.c
+++ b/missing/kqueue_inotify.c
@@ -81,7 +81,7 @@ fs_sysctl(const int name) {

 #define EVENT_SIZE (sizeof (struct inotify_event))
 #define EVENT_BUF_LEN (32 * (EVENT_SIZE + 16))
-#define IN_ALL IN_CLOSE_WRITE|IN_DELETE_SELF|IN_MOVE_SELF|IN_MOVE|IN_ATTRIB|IN_CREATE|IN_DELETE
+#define IN_ALL IN_MODIFY|IN_DELETE_SELF|IN_MOVE_SELF|IN_MOVE|IN_ATTRIB|IN_CREATE|IN_DELETE

 /*
  * inotify and kqueue ids both have the type `int`
@@ -193,7 +193,7 @@ kevent(int kq, const struct kevent *changelist, int nchanges, struct
                                /* convert iev->mask; to comparable kqueue flags */
                                fflags = 0;
                                if (iev->mask & IN_DELETE_SELF) fflags |= NOTE_DELETE;
-                               if (iev->mask & IN_CLOSE_WRITE) fflags |= NOTE_WRITE;
+                               if (iev->mask & IN_MODIFY)      fflags |= NOTE_WRITE;
                                if (iev->mask & IN_CREATE)      fflags |= NOTE_WRITE;
                                if (iev->mask & IN_DELETE)      fflags |= NOTE_WRITE;
                                if (iev->mask & IN_MOVE_SELF)   fflags |= NOTE_RENAME;

from entr.

eradman avatar eradman commented on June 30, 2024

This is as intended:

On Linux entr waits until the file closed (IN_CLOSE_WRITE) so that it does not launch utilities before a file is completely written. (Downloading a file for example.)

Unfortunately kqueue does not prove this insight, so on BSD entr may run the utility on a file that is partially written.

from entr.

kwastek avatar kwastek commented on June 30, 2024

That's a shame :(

I don't mind entr reacting to each small file change. In my script I use sleep at the beginning, before I process the modified file. That way I give time for the serial transmission to finish. I ended up using the when-changed utility. But I think it would be nice for entr to have this functionality as well.

I understand your reasoning, but I think it would be great to have a switch for this behavior.

from entr.

eradman avatar eradman commented on June 30, 2024

entr is a test runner, so the primary objective is to avoid spurious changes by collapsing events so that

  1. a build is not triggered prematurely
  2. a build is only invoked only once

What your use case? If you're looking to respond to all events, perhaps inotifywait is the right tool

inotifywait -q -e modify testfile.log --format "%w%f"

from entr.

kwastek avatar kwastek commented on June 30, 2024

Thank you very much. It is even able to react to changes in all files in a folder:

inotifywait -q -e modify SerialLogs/ --format "%w%f"

My use case is that I capture logs from a serial console of an embedded devices, and want to send an email when any of the devices resets. So I want some tool that will notice a change in the log file, so I'm able to grep it for more details and then take further actions.

I think for now I'll stay with the when-changed utility since it works the way I need it and also is able to directly execute a command like entr does. But if it turns out I need more control over what is happening, then I'll go with the inotifywait route.

Thank you for taking the time to help me!

from entr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.