summaryrefslogtreecommitdiff
path: root/ev.c
diff options
context:
space:
mode:
authorroot <root>2009-08-26 17:46:22 +0000
committerroot <root>2009-08-26 17:46:22 +0000
commit647f4426ab73858145d0d67dadf3ff45ff8402f6 (patch)
tree7332eea9c8d78ff08b7ec666f0971c616db9cb48 /ev.c
parent8be7dacbb351237aba5cad021ffe1298a4e3c1c8 (diff)
*** empty log message ***
Diffstat (limited to 'ev.c')
-rw-r--r--ev.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/ev.c b/ev.c
index 2403b32..ddfbe8b 100644
--- a/ev.c
+++ b/ev.c
@@ -2999,6 +2999,17 @@ check_2625 (EV_P)
fs_2625 = 1;
}
+inline_size int
+infy_newfd (void)
+{
+#if defined (IN_CLOEXEC) && defined (IN_NONBLOCK)
+ int fd = inotify_init1 (IN_CLOEXEC | IN_NONBLOCK);
+ if (fd >= 0)
+ return fd;
+#endif
+ return inotify_init ();
+}
+
inline_size void
infy_init (EV_P)
{
@@ -3009,10 +3020,11 @@ infy_init (EV_P)
check_2625 (EV_A);
- fs_fd = inotify_init ();
+ fs_fd = infy_newfd ();
if (fs_fd >= 0)
{
+ fd_intern (fs_fd);
ev_io_init (&fs_w, infy_cb, fs_fd, EV_READ);
ev_set_priority (&fs_w, EV_MAXPRI);
ev_io_start (EV_A_ &fs_w);
@@ -3027,8 +3039,16 @@ infy_fork (EV_P)
if (fs_fd < 0)
return;
+ ev_io_stop (EV_A_ &fs_w);
close (fs_fd);
- fs_fd = inotify_init ();
+ fs_fd = infy_newfd ();
+
+ if (fs_fd >= 0)
+ {
+ fd_intern (fs_fd);
+ ev_io_set (&fs_w, fs_fd, EV_READ);
+ ev_io_start (EV_A_ &fs_w);
+ }
for (slot = 0; slot < EV_INOTIFY_HASHSIZE; ++slot)
{