From: Olof-Joachim Frahm Date: Fri, 29 Mar 2013 00:27:15 +0000 (+0100) Subject: Fix possibly missing inotify_init1(2). X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=68818178b7e34babfeef66d1e7166fd74df21170;p=cl-inotify.git Fix possibly missing inotify_init1(2). --- diff --git a/grovel.lisp b/grovel.lisp index c59de22..fbe9a1e 100644 --- a/grovel.lisp +++ b/grovel.lisp @@ -30,6 +30,7 @@ (include "sys/inotify.h") +;; since 2.6.27 according to inotify_init(2) (constant (in-cloexec "IN_CLOEXEC")) (constant (in-nonblock "IN_NONBLOCK")) (constant (in-access "IN_ACCESS")) diff --git a/inotify.lisp b/inotify.lisp index ee4435b..8c97386 100644 --- a/inotify.lisp +++ b/inotify.lisp @@ -28,6 +28,11 @@ (in-package #:cl-inotify) +(eval-when (:compile-toplevel :load-toplevel :execute) + (when (boundp 'in-cloexec) + (pushnew 'inotify1 *features*))) + +#+cl-inotify::inotify1 (defbitfield (inotify1-flag :int) (:cloexec #.in-cloexec) (:nonblock #.in-nonblock)) @@ -97,6 +102,7 @@ thus should be used only with WATCH-RAW)." (defsyscall inotify-init :int "Initialises a new inotify event queue.") +#+cl-inotify::inotify1 (defsyscall inotify-init1 :int "Initialises a new inotify event queue and passes some flags along." (flags inotify1-flag)) @@ -198,8 +204,14 @@ the file descriptor is set to non-blocking I/O." (unwind-protect ;; file descriptor is collected with auto-close (progn - (setf fd (inotify-init1 (and (setf non-block nonblocking) - :nonblock))) + (setf non-block nonblocking) + #+inotify1 + (setf fd (inotify-init1 (and non-block :nonblock))) + #-inotify1 + (setf fd (inotify-init)) + #-inotify1 + (when non-block + (set-nonblocking fd T)) (setf stream ;; TODO: what about the blocking? #-(or clisp sbcl)