Giter Club home page Giter Club logo

Comments (9)

eradman avatar eradman commented on June 30, 2024

Just a guess:

If you run ps -x do you see entr in the state T (stopped)?

If so you can fix this by adding -n to avoid opening STDIN.

from entr.

b0o avatar b0o commented on June 30, 2024

When I run ps -x after entr has stopped responding to events, I see this: 873817 pts/10 S+ 0:00 entr echo modified. Adding -n to the entr command does not help.

I should also note that if I have entr watch multiple files including the script that executes it (e.g. echo -n "foo.txt\nbar.txt\ntest.sh" | entr echo "modified") it will still only respond to a single event from the script file that executed it, but it will continue to respond to events from the other files.

from entr.

eradman avatar eradman commented on June 30, 2024

I wasn't able to reproduce this problem using Ubuntu 22.04 (Linux 5.15). I can see that the inode changes after modifying the file with vim

$ ls -li test.sh
1051650 -rwxrwxr-x 1 eradman eradman 49 Dec 11 10:15 test.sh
$ vim test.sh
$ ls -li test.sh
1051648 -rwxrwxr-x 1 eradman eradman 50 Dec 11 10:16 test.sh
$ vim test.sh
$ ls -li test.sh
1051645 -rwxrwxr-x 1 eradman eradman 49 Dec 11 10:16 test.sh

Each time entr responds

$ ./test.sh
modified
modified
modified

Can you run the same experiement with EV_TRACE=1 ./test.sh?

I'll spin up an Arch Linux instance to see if I see different behavior on a 6.6 kernel

from entr.

eradman avatar eradman commented on June 30, 2024

Here was the output I received using a 6.1 kernel

$ EV_TRACE=1 ./test.sh
open_max: 524288
modified
0/1: fflags: 0x28 r 100755 ./test.sh
modified
0/1: fflags: 0x29 r 100755 ./test.sh
modified
$ uname
Linux arch 6.1.65-1-lts #1 SMP PREEMPT_DYNAMIC Sun, 03 Dec 2023 12:06:12 +0000 x86_64 GNU/Linux

from entr.

b0o avatar b0o commented on June 30, 2024

I get this, the output just stops after the first event even if I keep writing the file:

$ EV_TRACE=1 ./test.sh                                                                                                      14:28:58
open_max: 524288
modified
0/1: fflags: 0x8 r 100755 ./test.sh
modified

I'm going to reboot in a little while and try the base kernel (currently using xanmod).

from entr.

eradman avatar eradman commented on June 30, 2024

For reference, fflags on Linux represents the following events:

#define IN_ACCESS·  ·   0x00000001· /* File was accessed */
#define IN_MODIFY·  ·   0x00000002· /* File was modified */
#define IN_ATTRIB·  ·   0x00000004· /* Metadata changed */
#define IN_CLOSE_WRITE· ·   0x00000008· /* Writtable file was closed */
#define IN_CLOSE_NOWRITE·   0x00000010· /* Unwrittable file closed */
#define IN_OPEN··   ·   0x00000020· /* File was opened */
#define IN_MOVED_FROM·  ·   0x00000040· /* File was moved from X */
#define IN_MOVED_TO··   0x00000080· /* File was moved to Y */
#define IN_CREATE·  ·   0x00000100· /* Subfile was created */
#define IN_DELETE·  ·   0x00000200· /* Subfile was deleted */
#define IN_DELETE_SELF· ·   0x00000400· /* Self was deleted */
#define IN_MOVE_SELF·   ·   0x00000800· /* Self was moved */

from entr.

b0o avatar b0o commented on June 30, 2024

I tweaked my test a bit:

#!/usr/bin/env bash
printf '%s\n' ./test.sh ./foobar.txt | entr -pn basename /_

...and added a foobar.txt file. Here's the output when I write foobar.txt 3 times, then test.sh 3 times:

$ EV_TRACE=1 ./test.sh                                                                                                      
open_max: 524288
0/1: fflags: 0x9 r 100644 ./foobar.txt
foobar.txt
0/1: fflags: 0x9 r 100644 ./foobar.txt
foobar.txt
0/1: fflags: 0x9 r 100644 ./foobar.txt
foobar.txt
0/1: fflags: 0x8 r 100755 ./test.sh
test.sh

Not sure why there is a difference in the fflags between the events for the two files. Is that indicative of anything?

from entr.

eradman avatar eradman commented on June 30, 2024

I have a theory about what's happening

inotify does not deliver some events while a file is open (including running binaries). In this case IN_CLOSE_NOWRITE and IN_DELETE_SELF does not seem to be not sent until test.sh completes.

If you save a file (with VIM for example) the file is replaced, but entr does not open the file again for monitoring since it never saw that the file was unlinked.

If this explanation is correct, this is essentially a deadlock because entr won't see events until the script completes...which it never happen since this script blocks while running entr

$ sudo fuser test.sh
/home/eradman/test.sh: 514923

from entr.

eradman avatar eradman commented on June 30, 2024

@b0o feel free to reopen if you think there is a problem we should investigate further.

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.