File: README

package info (click to toggle)
fswatch 1.14.0+repack-13
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 1,460 kB
  • sloc: cpp: 4,557; makefile: 184; sed: 16
file content (303 lines) | stat: -rw-r--r-- 11,859 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
[![License](https://img.shields.io/badge/license-GPL--3.0-blue.svg?style=flat)](https://github.com/emcrisostomo/fswatch/blob/master/COPYING)
[![Build Status](https://travis-ci.org/emcrisostomo/fswatch.svg?branch=master)](https://travis-ci.org/emcrisostomo/fswatch)

README
======

`fswatch` is a file change monitor that receives notifications when the contents
of the specified files or directories are modified.  `fswatch` implements
several monitors:

  * A monitor based on the _File System Events API_ of Apple OS X.
  * A monitor based on _kqueue_, a notification interface introduced in FreeBSD
    4.1 (and supported on most *BSD systems, including OS X).
  * A monitor based on the _File Events Notification_ API of the Solaris kernel
    and its derivatives.
  * A monitor based on _inotify_, a Linux kernel subsystem that reports file
    system changes to applications.
  * A monitor based on _ReadDirectoryChangesW_, a Microsoft Windows API that
    reports changes to a directory.
  * A monitor which periodically stats the file system, saves file modification
    times in memory, and manually calculates file system changes (which works
    anywhere `stat (2)` can be used).

`fswatch` should build and work correctly on any system shipping either of the
aforementioned APIs.

Table of Contents
-----------------

  * [libfswatch](#libfswatch)
  * [Features](#features)
  * [Limitations](#limitations)
  * [Getting fswatch](#getting-fswatch)
  * [Building from Source](#building-from-source)
  * [Installation](#installation)
  * [Documentation](#documentation)
  * [Localization](#localization)
  * [Usage](#usage)
  * [Contributing](#contributing)
  * [Bug Reports](#bug-reports)

libfswatch
----------

`fswatch` is a frontend of `libfswatch`, a library with C and C++ binding.  More
information on `libfswatch` can be found [here][README.libfswatch.md]. 

[README.libfswatch.md]: README.libfswatch.md

Features
--------

`fswatch` main features are:

  * Support for many OS-specific APIs such as kevent, inotify, and FSEvents.
  * Recursive directory monitoring.
  * Path filtering using including and excluding regular expressions.
  * Customizable record format.
  * Support for periodic idle events.

Limitations
-----------

The limitations of `fswatch` depend largely on the monitor being used:

  * The **FSEvents** monitor, available only on OS X, has no known limitations,
    and scales very well with the number of files being observed.

  * The **File Events Notification** monitor, available on Solaris kernels and
    its derivatives, has no known limitations.

  * The **kqueue** monitor, available on any \*BSD system featuring kqueue,
    requires a file descriptor to be opened for every file being watched.  As a
    result, this monitor scales badly with the number of files being observed,
    and may begin to misbehave as soon as the `fswatch` process runs out of file
    descriptors.  In this case, `fswatch` dumps one error on standard error for
    every file that cannot be opened.

  * The **inotify** monitor, available on Linux since kernel 2.6.13, may suffer
    a queue overflow if events are generated faster than they are read from the
    queue.  In any case, the application is guaranteed to receive an overflow
    notification which can be handled to gracefully recover.  `fswatch`
    currently throws an exception if a queue overflow occurs.  Future versions
    will handle the overflow by emitting proper notifications.

  * The **Windows** monitor can only establish a watch _directories_, not files.
    To watch a file, its parent directory must be watched in order to receive
    change events for all the directory's children, _recursively_ at any depth.
    Optionally, change events can be filtered to include only changes to the
    desired file.

  * The **poll** monitor, available on any platform, only relies on
    available CPU and memory to perform its task.  The performance of this
    monitor degrades linearly with the number of files being watched.

Usage recommendations are as follows:

  * On OS X, use only the `FSEvents` monitor (which is the default behaviour).

  * On Solaris and its derivatives use the _File Events Notification_ monitor.

  * On Linux, use the `inotify` monitor (which is the default behaviour).

  * If the number of files to observe is sufficiently small, use the `kqueue`
    monitor.  Beware that on some systems the maximum number of file descriptors
    that can be opened by a process is set to a very low value (values as low as
    256 are not uncommon), even if the operating system may allow a much larger
    value.  In this case, check your OS documentation to raise this limit on
    either a per process or a system-wide basis.

  * If feasible, watch directories instead of files.  Properly crafting the
    receiving side of the events to deal with directories may sensibly reduce
    the monitor resource consumption.

  * On Windows, use the `windows` monitor.

  * If none of the above applies, use the poll monitor.  The authors' experience
    indicates that `fswatch` requires approximately 150 MB of RAM memory to
    observe a hierarchy of 500.000 files with a minimum path length of 32
    characters.  A common bottleneck of the poll monitor is disk access, since
    `stat()`-ing a great number of files may take a huge amount of time.  In
    this case, the latency should be set to a sufficiently large value in order
    to reduce the performance degradation that may result from frequent disk
    access.

Getting fswatch
---------------

A regular user may be able to fetch `fswatch` from the package manager of your
OS or a third-party one.  If you are looking for `fswatch` for OS X, you can
install it using either [MacPorts] or [Homebrew]:

```
# MacPorts
$ port install fswatch

# Homebrew
$ brew install fswatch
```

Check your favourite package manager and let us know if `fswatch` is missing
there.

[MacPorts]: https://www.macports.org
[Homebrew]: http://brew.sh

Building from Source
--------------------

A user who wishes to build `fswatch` should get a [release tarball][release].
A release tarball contains everything a user needs to build `fswatch` on their
system, following the instructions detailed in the Installation section below
and the `INSTALL` file.

A developer who wishes to modify `fswatch` should get the sources (either from a
source tarball or cloning the repository) and have the GNU Build System
installed on their machine.  Please read `README.gnu-build-system` to get further
details about how to bootstrap `fswatch` from sources on your machine.

Getting a copy of the source repository is not recommended unless you are a
developer, you have the GNU Build System installed on your machine, and you know
how to bootstrap it on the sources.

[release]: https://github.com/emcrisostomo/fswatch/releases

Installation
------------

See the `INSTALL` file for detailed information about how to configure and
install `fswatch`.  Since the `fswatch` builds and uses dynamic libraries, in
some platforms you may need to perform additional tasks before you can use
`fswatch`:

  * Make sure the installation directory of dynamic libraries (`$PREFIX/lib`) is
    included in the lookup paths of the dynamic linker of your operating system.
    The default path, `/usr/local/lib`, will work in nearly every operating
    system.
  * Refreshing the links and cache to the dynamic libraries may be required.  In
    GNU/Linux systems you may need to run `ldconfig`:

        $ ldconfig

`fswatch` is a C++ program and a C++ compiler compliant with the C++11 standard
is required to compile it.  Check your OS documentation for information about
how to install the C++ toolchain and the C++ runtime.

No other software packages or dependencies are required to configure and install
`fswatch` but the aforementioned APIs used by the file system monitors.

Documentation
-------------

`fswatch` provides the following [documentation]:

  * Texinfo documentation, included with the distribution.
  * HTML documentation.
  * PDF documentation.
  * A [wiki] page.
  * A man page.

`fswatch` official documentation is provided in Texinfo format.  This is the
most comprehensive source of information about `fswatch` and the only
authoritative one.  The man page, in particular, is a stub that suggests the
user to use the info page instead.

If you are installing `fswatch` using a package manager and you would like the
PDF manual to be bundled into the package, please send a feature request to the
package maintainer.

[documentation]: http://emcrisostomo.github.io/fswatch/doc
[wiki]: https://github.com/emcrisostomo/fswatch/wiki

Localization
------------

`fswatch` is localizable and internally uses GNU `gettext` to decouple
localizable string from their translation.  The currently available locales are:

  * English (`en`).
  * Italian (`it`).
  * Spanish (`es`).

To build `fswatch` with localization support, you need to have `gettext`
installed on your system.  If `configure` cannot find `<libintl.h>` or the
linker cannot find `libintl`, then you may need to manually provide their
location to `configure`, usually using the `CPPFLAGS` and the `LDFLAGS`
variables.  See `README.osx` for an example.

If `gettext` is not available on your system, `fswatch` shall build correctly,
but it will lack localization support and the only available locale will be
English.

Usage
-----

`fswatch` accepts a list of paths for which change events should be received:

    $ fswatch [options] ... path-0 ... path-n

The event stream is created even if any of the paths do not exist yet.  If they
are created after `fswatch` is launched, change events will be properly
received.  Depending on the watcher being used, newly created paths will be
monitored after the amount of configured latency has elapsed.

The output of `fswatch` can be piped to other program in order to process it
further:

    $ fswatch -0 path | while read -d "" event \
      do \
        // do something with ${event}
      done

To run a command when a set of change events is printed to standard output but
no event details are required, then the following command can be used:

    $ fswatch -o path | xargs -n1 -I{} program

The behaviour is consistent with earlier versions of `fswatch` (v. 0.x).
Please, read the _Compatibility Issues with fswatch v. 0.x_ section for further
information.

By default `fswatch` chooses the best monitor available on the current platform,
in terms of performance and resource consumption.  If the user wishes to specify
a different monitor, the `-m` option can be used to specify the monitor by name:

    $ fswatch -m kqueue_monitor path

The list of available monitors can be obtained with the `-h` option.

For more information, refer to the `fswatch` documentation.

Contributing
------------

Everybody is welcome to contribute to `fswatch`.  Please, see
[`CONTRIBUTING`][contrib] for further information.

[contrib]: CONTRIBUTING.md

Bug Reports
-----------

Bug reports can be sent directly to the authors.

Contact the Authors
-------------------

The author can be contacted on IRC, using the Freenode `#fswatch` channel.

-----

Copyright (c) 2013-2018 Enrico M. Crisostomo

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with
this program.  If not, see <http://www.gnu.org/licenses/>.