ioloop-notify-dn.c revision 01ac83a86f9f29741b585205eefeec9c0c546f8b
/* Copyright (C) 2003 Timo Sirainen */
/* Logic is pretty much based on dnotify by Oskar Liljeblad. */
#define _GNU_SOURCE
#include "lib.h"
#ifdef IOLOOP_NOTIFY_DNOTIFY
#include "ioloop-internal.h"
#include "fd-set-nonblock.h"
#include "fd-close-on-exec.h"
#include <signal.h>
#include <unistd.h>
#include <fcntl.h>
struct ioloop_notify_handler_context {
int disabled;
};
void *data __attr_unused__)
{
int ret;
i_fatal("write(event_pipe) failed: %m");
}
static void event_callback(void *context)
{
if (ret < 0)
i_fatal("read(event_pipe) failed: %m");
}
i_fatal("gettimeofday(): %m");
break;
}
}
}
{
struct ioloop_notify_handler_context *ctx =
int fd;
if (fd == -1) {
return NULL;
}
/* dnotify not in kernel. disable it. */
} else {
i_error("fcntl(F_SETSIG) failed: %m");
}
return NULL;
}
DN_MULTISHOT) < 0) {
/* we fail here if we're trying to add dnotify to
non-directory fd. fail silently in that case. */
i_error("fcntl(F_NOTIFY) failed: %m");
return NULL;
}
}
return io;
}
{
struct ioloop_notify_handler_context *ctx =
return;
break;
}
}
i_error("fcntl(F_NOTIFY, 0) failed: %m");
i_error("fcntl(F_SETSIG, 0) failed: %m");
i_error("close(dnotify) failed: %m");
}
}
{
struct ioloop_notify_handler_context *ctx;
if (pipe(event_pipe) < 0) {
i_fatal("pipe() failed: %m");
return;
}
/* SIGIO is sent if queue gets full. we'll just ignore it. */
i_fatal("sigaction(SIGRTMIN) failed: %m");
}
{
struct ioloop_notify_handler_context *ctx =
if (close(event_pipe[0]) < 0)
i_error("close(event_pipe[0]) failed: %m");
i_error("close(event_pipe[1]) failed: %m");
}
#endif