Skip to content

Commit 30f354f

Browse files
jorangreefMyles Borins
authored and
Myles Borins
committed
doc: clarify fs.watch() and inodes on linux, os x
On Linux and OS X systems, `fs.watch()` resolves the watched path to an inode. This clarifies that `fs.watch()` watches the inode and not the path. If the inode of the path subsequently changes, `fs.watch()` will continue watching the original inode and events for the path will no longer be emitted. This is expected behavior. Fixes: #5039 PR-URL: #6099 Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent d1fca27 commit 30f354f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

doc/api/fs.markdown

+11
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,16 @@ reliably or at all.
830830
You can still use `fs.watchFile`, which uses stat polling, but it is slower and
831831
less reliable.
832832

833+
#### Inodes
834+
835+
<!--type=misc-->
836+
837+
On Linux and OS X systems, `fs.watch()` resolves the path to an [inode][] and
838+
watches the inode. If the watched path is deleted and recreated, it is assigned
839+
a new inode. The watch will emit an event for the delete but will continue
840+
watching the *original* inode. Events for the new inode will not be emitted.
841+
This is expected behavior.
842+
833843
#### Filename Argument
834844

835845
<!--type=misc-->
@@ -1010,3 +1020,4 @@ Synchronous versions of [`fs.write()`][]. Returns the number of bytes written.
10101020
[MDN-Date]: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date
10111021
[Readable Stream]: stream.html#stream_class_stream_readable
10121022
[Writable Stream]: stream.html#stream_class_stream_writable
1023+
[inode]: http://www.linux.org/threads/intro-to-inodes.4130

0 commit comments

Comments
 (0)