Codebase list entr / e3c46d1
New upstream release. Debian Janitor 2 years ago
8 changed file(s) with 119 addition(s) and 97 deletion(s). Raw diff Collapse all Expand all
00 PREFIX ?= /usr/local
11 MANPREFIX ?= ${PREFIX}/man
2 RELEASE = 4.8
2 RELEASE = 5.0
33 CPPFLAGS += -DRELEASE=\"${RELEASE}\"
44
55 all: versioncheck entr
1616 @./system_test.sh
1717
1818 entr: entr.c ${EXTRA_SRC}
19 ${CC} ${CFLAGS} ${CPPFLAGS} ${EXTRA_SRC} entr.c -o $@ ${LDFLAGS}
19 ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} ${EXTRA_SRC} entr.c -o $@
2020
2121 entr_spec: entr_spec.c entr.c ${EXTRA_SRC}
22 ${CC} ${CFLAGS} ${CPPFLAGS} ${EXTRA_SRC} entr_spec.c -o $@ ${LDFLAGS}
22 ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} ${EXTRA_SRC} entr_spec.c -o $@
2323
2424 clean:
2525 rm -f entr entr_spec *.o
+28
-17
NEWS less more
00 = Release History
1
2 == 5.0: July 2, 2021
3
4 - Add missing call to getrlimit(3) on MacOS
5 - Eliminate memory management warnings on Linux
6 - EV_TRACE prints file mode and file name
7 - Ignore asynchronous attribute changes on MacOS 11
8
9 == 4.9: May 3, 2021
10
11 - EV_TRACE also prints file/notify descriptor limit
12 - Don't raise rlim_cur on MacOS
13 - Set 2^16 watches if inotify limits cannot be read
14 - Raise an error and suggest '-n' if terminal attributes cannot be read
115
216 == 4.8: February 26, 2021
317
2741
2842 - Use a single inotify queue on Linux, limited by
2943 /proc/sys/fs/inotify/max_user_watches
30 - Set the environment variable `ENTR_INOTIFY_WORKAROUND` to enable a
44 - Set the environment variable 'ENTR_INOTIFY_WORKAROUND' to enable a
3145 compatibility mode for platforms with deformed inotify support
3246
3347 == 4.3: September 25, 2019
108122 - Relocated 'reload-browser' to http://entrproject.org/scripts/reload-browser
109123 - Drop FIFO support to further simply code and documentation. FIFO mode was
110124 conceptually good, but EXEC mode is intelligent hand easily handles the vast
111 majority of use cases.
125 majority of use cases
112126 - Remove kFreeBSD as a target platform
113127
114128 == 3.1: March 4, 2015
131145
132146 == 2.9: June 10, 2014
133147
134 - RPM package by @funollet
135148 - Moved alternate Makefiles to contrib/
136149 - Trigger actions when a file is truncated on BSD
137150 - Improved format of DEBUG messages
139152 - No longer register NOTE_EXTEND; this event is not always merged with
140153 NOTE_WRITE on MacOS
141154 - New directory-watch option ('-d'). In this mode a shell while-loop can be
142 used to track the addition of new files.
155 used to track the addition of new files
143156
144157
145158 == 2.8: March 15, 2014
147160 - Iteratively check for new file system events using a 1ms timeout after a file
148161 has been renamed or removed in order to prevent the utility from being
149162 executed before successive changes from a version control system have
150 completed.
151 - Regression tests are now system tests that depend on and use Vim and
152 Mercurial
163 completed
164 - Regression tests use Vim and Mercurial
153165 - Timing on regression tests has been tightened to only support real hardware;
154 they are not expected to pass in emulated environments.
166 they are not expected to pass in emulated environments
155167 - More correctly identify the first file to trigger a file change notification
156 - Regression tests no longer require ksh
157 - Renamed regress.sh to system_test.sh
168 - Renamed regress.sh to system_test.sh, and drop dependency on ksh
158169
159170 == 2.7: February 12, 2014
160171
161172 - Changed function pointer prefixes from '_' to 'x' to avoid runtime symbol
162173 collisions in libc. Required to build on DragonFlyBSD
163 - Added this NEWS file to provide detailed release history for port maintainers
174 - Add this NEWS file to provide detailed release history for port maintainers
164175 - Subsitute '/_' argument with the first file that changed
165176 - Man page formatted with more semantically correct markup
166177 - Multiple events on the same file are merged on Linux to prevent duplicate
176187 - Raise ARG_MAX from 4K to 2MB on Linux, since _SC_ARG_MAX returns an incorrect
177188 value on Linux
178189 - Handle RENAME events that are not followed by DELETE. This enables us to cope
179 with the backup option in Vim.
190 with the backup option in Vim
180191
181192 == 2.5: December 30, 2013
182193
183194 - Restore full 50ms period for consolidating events on Linux. Required for the
184195 Geany editor
185 - Remove use of setproctitle(3), no plans to implement this on Linux and MacOS.
196 - Remove use of setproctitle(3), no plans to implement this on Linux and MacOS
186197 This also eliminates use of the 3-clause license
187198 - New feature: the first occurrence of '{}' on the command line will be
188199 replaced with the name of the first file under watch
215226 - Exit non-zero if list of regular files exceeds the hard limit set by the
216227 current login class
217228 - Ignore directories and special files; exit with error code 1 if no regular
218 files are provided as input.
229 files are provided as input
219230
220231 == 2.1: July 01, 2013
221232
237248
238249 == 1.9: April 13, 2013
239250
240 - New auto-reload option ('-r'). Thanks for Kevin Cox for the idea
251 - New auto-reload option ('-r')
241252 - Add a simple configure script, BSD is the default
242253 - Do not install directories...they should already exist
243254 - Man page installation path can be set with MANPATH. MacOS expects it to be
272283
273284 == 1.3: May 17, 2012
274285
275 - Added FIFO support. Thanks to James K. Lowden for the idea
276 - Use min(OPEN_MAX, rl.rlim_max) to be more compatible of Mac OS.
286 - Added FIFO support
287 - Use min(OPEN_MAX, rl.rlim_max) to be more compatible of Mac OS
277288 - More correct use of fgets(3) when reading STDIN
278289
279290 == 1.2: April 26, 2012
3535
3636 Launch and auto-reload a node.js server:
3737
38 $ find . -name '*.js' | entr -r node app.js
38 $ ls *.js | entr -r node app.js
3939
4040 Clear the screen and run a query after the SQL script is updated:
4141
42 $ echo my.sql | entr -p psql -f /_
42 $ echo my.sql | entr -cp psql -f /_
4343
4444 Rebuild project if a source file is modified or added to the src/ directory:
4545
46 $ while sleep 0.1; do find src -name '*.rb' | entr -d make; done
46 $ while sleep 0.1; do ls src/*.rb | entr -d make; done
4747
48 Self-terminate after a file is updated
48 Auto-reload a web server, or terminate if the server exits
4949
50 $ find . -type f | entr -p 'kill $PPID'
50 $ ls * | entr -rz ./httpd
5151
5252 News
5353 ----
0 entr (5.0-1) UNRELEASED; urgency=low
1
2 * New upstream release.
3
4 -- Debian Janitor <janitor@jelmer.uk> Mon, 09 Aug 2021 11:47:54 -0000
5
06 entr (4.8-1) unstable; urgency=medium
17
28 [ Yuri D'Elia ]
1212 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1313 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1414 .\"
15 .Dd February 18, 2021
15 .Dd July 2, 2021
1616 .Dt ENTR 1
1717 .Os
1818 .Sh NAME
123123 .Aq Cm control-C .
124124 .El
125125 .Sh ENVIRONMENT
126 If
127 .Ev PAGER
128 is undefined,
129 .Nm
130 will assign
126 .Bl -tag -width "ENTR_ENVIRON"
127 .It Ev PAGER
128 Set to
131129 .Pa /bin/cat
130 by default
132131 to prevent interactive utilities from waiting for keyboard input if output does
133132 not fit on the screen.
134 .Pp
135 If
136 .Ev SHELL
137 is undefined,
138 .Nm entr
139 will use
133 .It Ev SHELL
134 Specify the shell to use with the
135 .Fl s
136 flag.
137 The default is
140138 .Pa /bin/sh .
139 .It Ev EV_TRACE
140 Print file system event messages.
141 .El
141142 .Sh EXIT STATUS
142143 If the
143144 .Fl z
105105 int
106106 main(int argc, char *argv[]) {
107107 struct rlimit rl;
108 rlim_t max_watches;
109108 int kq;
110109 struct sigaction act;
111110 int ttyfd;
113112 int n_files;
114113 int i;
115114 struct kevent evSet;
116 long open_max;
115 unsigned open_max;
117116
118117 if ((*test_runner_main))
119118 return(test_runner_main(argc, argv));
158157 if (sigaction(SIGCHLD, &act, NULL) != 0)
159158 err(1, "Failed to set SIGCHLD handler");
160159
161 getrlimit(RLIMIT_NOFILE, &rl);
162
163160 #if defined(_LINUX_PORT)
164 max_watches = (rlim_t)fs_sysctl(INOTIFY_MAX_USER_WATCHES);
165 if(max_watches > 0) {
166 rl.rlim_cur = max_watches;
167 open_max = max_watches;
168 goto rlim_set;
169 }
170 #endif
171 /* raise soft limit */
172 open_max = min(sysconf(_SC_OPEN_MAX), (long)rl.rlim_max);
173 if (open_max == -1)
174 err(1, "_SC_OPEN_MAX");
175
176 open_max = min(524288, open_max); /* guard against unrealistic replies */
177
161 /* attempt to read inotify limits */
162 open_max = (unsigned)fs_sysctl(INOTIFY_MAX_USER_WATCHES);
163 if (open_max == 0)
164 open_max = 65536;
165 #elif defined(_MACOS_PORT)
166 if (getrlimit(RLIMIT_NOFILE, &rl) == -1)
167 err(1, "getrlimit");
168 /* guard against unrealistic replies */
169 open_max = min(65536, (unsigned)rl.rlim_cur);
170 if (open_max == 0)
171 open_max = 65536;
172 #else /* BSD */
173 if (getrlimit(RLIMIT_NOFILE, &rl) == -1)
174 err(1, "getrlimit");
175 open_max = (unsigned)rl.rlim_max;
178176 rl.rlim_cur = (rlim_t)open_max;
179177 if (setrlimit(RLIMIT_NOFILE, &rl) != 0)
180 err(1, "setrlimit cannot set rlim_cur to %ld", open_max);
181
182 rlim_set:
178 err(1, "setrlimit cannot set rlim_cur to %u", open_max);
179 #endif
180
181 if (getenv("EV_TRACE"))
182 fprintf(stderr, "open_max: %d\n", open_max);
183183
184184 /* prevent interactive utilities from paging output */
185185 setenv("PAGER", "/bin/cat", 0);
203203 errx(1, "No regular files to watch");
204204 if (n_files == -1)
205205 errx(1, "Too many files listed; the hard limit for your login"
206 " class is %ld. Please consult"
206 " class is %u. Please consult"
207207 " http://eradman.com/entrproject/limits.html", open_max);
208208 for (i=0; i<n_files; i++)
209209 watch_file(kq, files[i]);
218218 }
219219
220220 /* remember terminal settings */
221 tcgetattr(STDIN_FILENO, &canonical_tty);
221 if (tcgetattr(STDIN_FILENO, &canonical_tty) == -1)
222 errx(1, "unable to get terminal attributes, use '-n' to run non-interactively");
222223
223224 /* Use keyboard input as a trigger */
224225 EV_SET(&evSet, STDIN_FILENO, EVFILT_READ, EV_ADD, NOTE_LOWAT, 1, NULL);
260261 void
261262 handle_exit(int sig) {
262263 if (!noninteractive_opt)
263 xtcsetattr(0, TCSADRAIN, &canonical_tty);
264 xtcsetattr(STDIN_FILENO, TCSADRAIN, &canonical_tty);
264265 terminate_utility();
265266 if ((sig == SIGINT || sig == SIGHUP))
266267 exit(0);
416417 char **new_argv;
417418 char *p, *arg_buf;
418419 int argc;
419 int stdin_pipe[2];
420 int stdin_pipe[2] = {0, 0};
420421
421422 if (restart_opt == 1) {
422423 terminate_utility();
586587 struct stat sb;
587588 char c;
588589 struct termios character_tty;
589 char *trace_message;
590590
591591 leading_edge = files[0]; /* default */
592592 if (postpone_opt == 0)
600600
601601 main:
602602 if (!noninteractive_opt)
603 xtcsetattr(0, TCSADRAIN, &character_tty);
603 xtcsetattr(STDIN_FILENO, TCSADRAIN, &character_tty);
604604 if ((reopen_only == 1) || (collate_only == 1)) {
605605 nev = xkevent(kq, NULL, 0, evList, 32, &evTimeout);
606606 }
639639 dir_modified += compare_dir_contents(file);
640640 }
641641 if (!noninteractive_opt)
642 xtcsetattr(0, TCSADRAIN, &canonical_tty);
642 xtcsetattr(STDIN_FILENO, TCSADRAIN, &canonical_tty);
643643
644644 collate_only = 0;
645645 for (i=0; i<nev; i++) {
667667 }
668668
669669 for (i=0; i<nev && reopen_only == 0; i++) {
670 trace_message = "";
671670
672671 if (evList[i].filter != EVFILT_VNODE)
673672 continue;
689688 if (file->mode != sb.st_mode) {
690689 do_exec = 1;
691690 file->mode = sb.st_mode;
692 trace_message = "mode changed";
693691 }
694692 /* Possible on Linux when a running binary is unlinked */
695693 if (file->ino != sb.st_ino) {
696694 do_exec = 1;
697695 file->ino = sb.st_ino;
698 trace_message = "inode changed";
699696 }
700697 }
701698 else if (evList[i].fflags & NOTE_ATTRIB)
702699 continue;
703700
704 if ((file->is_dir == 0) && (leading_edge_set == 0)) {
701 if ((leading_edge_set == 0) &&
702 (file->is_dir == 0) &&
703 (do_exec == 1)) {
705704 leading_edge = file;
706705 leading_edge_set = 1;
707706 }
708707
709708 if (getenv("EV_TRACE")) {
710 fprintf(stderr, "EVFILT_VNODE: %d/%d: "
711 "fflags: 0x%x %s\n", i, nev, evList[i].fflags,
712 trace_message);
709 fprintf(stderr, "%d/%d: fflags: 0x%x %s %o %s\n",
710 i, nev,
711 evList[i].fflags,
712 file->is_dir ? "d" : "r",
713 file->mode,
714 file->fn);
713715 }
714716 }
715717
5656 fs_sysctl(const int name) {
5757 FILE *file;
5858 char line[8];
59 int value;
59 int value = 0;
6060
6161 switch(name) {
6262 case INOTIFY_MAX_USER_WATCHES:
113113 struct inotify_event *iev;
114114 u_int fflags;
115115 const struct kevent *kev;
116 int ignored;
117 struct pollfd *pfd;
118116 int nfds;
119117
120 pfd = calloc(2, sizeof(struct pollfd));
118 int ignored = 0;
119 struct pollfd pfd[2];
120
121121 pfd[0].fd = kq;
122122 pfd[0].events = POLLIN;
123123 pfd[1].fd = STDIN_FILENO;
124124 pfd[1].events = POLLIN;
125125
126126 if (nchanges > 0) {
127 ignored = 0;
128127 for (n=0; n<nchanges; n++) {
129128 kev = changelist + (sizeof(struct kevent)*n);
130129 file = (WatchFile *)kev->udata;
229228 }
230229 while ((poll(pfd, nfds, 50) > 0));
231230
232 free(pfd);
233231 return n;
234232 }
220220 fi
221221
222222 try "exec single utility when an entire stash of files is reverted"
223 setup
224 cp /usr/include/*.h $tmp/
225 cd $tmp
226 git init -q
227 git add *.h
228 git commit -m "initial checkin" -q
229 for f in `ls *.h | head`; do
230 chmod 644 $f
231 echo "" >> $f
232 done
233 cd - > /dev/null ; zz
234 ls $tmp/*.h | ./entr -p echo "changed" > $tmp/exec.out &
235 bgpid=$! ; zz
236 cd $tmp
237 git checkout *.h -q
238 cd - > /dev/null ; zz
239 kill -INT $bgpid
240 wait $bgpid || assert "$?" "130"
241 assert "$(cat $tmp/exec.out)" "changed"
223 if [ ! -d /usr/include ]; then
224 skip "Operating system does not include files in a standard location"
225 else
226 setup
227 cp /usr/include/*.h $tmp/
228 cd $tmp
229 git init -q
230 git add *.h
231 git commit -m "initial checkin" -q
232 for f in `ls *.h | head`; do
233 chmod 644 $f
234 echo "" >> $f
235 done
236 cd - > /dev/null ; zz
237 ls $tmp/*.h | ./entr -p echo "changed" > $tmp/exec.out &
238 bgpid=$! ; zz
239 cd $tmp
240 git checkout *.h -q
241 cd - > /dev/null ; zz
242 kill -INT $bgpid
243 wait $bgpid || assert "$?" "130"
244 assert "$(cat $tmp/exec.out)" "changed"
245 fi
242246
243247 try "exec utility when a file is written by Vim"
244248 setup