2013-07-11 Paul Eggert <eggert@cs.ucla.edu>
+ * inotify.c (uninitialized): Remove. All uses replaced by -1.
+ (Finotify_add_watch): Simplify, since -1 means uninitialized now.
+ Touch up doc a bit.
+
* eval.c (backtrace_function, backtrace_args): Now EXTERNALLY_VISIBLE.
This is for .gdbinit xbacktrace.
# define IN_ONLYDIR 0
#endif
-enum { uninitialized = -100 };
/* File handle for inotify. */
-static int inotifyfd = uninitialized;
+static int inotifyfd = -1;
/* Assoc list of files being watched.
Format:
DEFUN ("inotify-add-watch", Finotify_add_watch, Sinotify_add_watch, 3, 3, 0,
doc: /* Add a watch for FILE-NAME to inotify.
-A WATCH-DESCRIPTOR is returned on success. ASPECT might be one of the following
-symbols or a list of those symbols:
+Return a watch descriptor. The watch will look for ASPECT events and
+invoke CALLBACK when an event occurs.
+
+ASPECT might be one of the following symbols or a list of those symbols:
access
attrib
move
close
-The following symbols can also be added to a list of aspects
+The following symbols can also be added to a list of aspects:
dont-follow
excl-unlink
oneshot
onlydir
-Watching a directory is not recursive. CALLBACK gets called in case of an
-event. It gets passed a single argument EVENT which contains an event structure
-of the format
+Watching a directory is not recursive. CALLBACK is passed a single argument
+EVENT which contains an event structure of the format
(WATCH-DESCRIPTOR ASPECTS NAME COOKIE)
CHECK_STRING (file_name);
- if (inotifyfd == uninitialized)
+ if (inotifyfd < 0)
{
inotifyfd = inotify_init1 (IN_NONBLOCK|IN_CLOEXEC);
- if (inotifyfd == -1)
- {
- inotifyfd = uninitialized;
- xsignal1
- (Qfile_notify_error,
- build_string ("File watching feature (inotify) is not available"));
- }
+ if (inotifyfd < 0)
+ xsignal1
+ (Qfile_notify_error,
+ build_string ("File watching feature (inotify) is not available"));
watch_list = Qnil;
add_read_fd (inotifyfd, &inotify_callback, NULL);
}
{
close (inotifyfd);
delete_read_fd (inotifyfd);
- inotifyfd = uninitialized;
+ inotifyfd = -1;
}
return Qt;