Så här står det i man 7 inotify:
Kod: Markera allt
Since Linux 2.6.25, signal-driven I/O notification is available for
inotify file descriptors; see the discussion of F_SETFL (for setting
the O_ASYNC flag), F_SETOWN, and F_SETSIG in fcntl(2). The siginfo_t
structure (described in sigaction(2)) that is passed to the signal han-
dler has the following fields set: si_fd is set to the inotify file
descriptor number; si_signo is set to the signal number; si_code is set
to POLL_IN; and POLLIN is set in si_band.
Kod: Markera allt
#include <unistd.h>
#include <fcntl.h>
#include <sys/inotify.h>
int main() {
int fd = inotify_init();
inotify_add_watch(fd, "testfil", IN_ALL_EVENTS);
fcntl(fd, F_SETFL, O_ASYNC);
fcntl(fd, F_SETOWN, getpid());
for (;;) sleep(1);
}
Lustigt nog så fungerar SIGIO bra om jag kör med en vanlig fifo istället:
Kod: Markera allt
#include <unistd.h>
#include <fcntl.h>
int main() {
int fd = open("testfifo", O_RDWR);
fcntl(fd, F_SETFL, O_ASYNC);
fcntl(fd, F_SETOWN, getpid());
for (;;) sleep(1);
}
Varför fungerar det inte med inotify? Några idéer?