From owner-freebsd-hackers Wed May 2 14:24:47 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from hotmail.com (f45.law8.hotmail.com [216.33.241.45]) by hub.freebsd.org (Postfix) with ESMTP id 852A737B440 for ; Wed, 2 May 2001 14:24:42 -0700 (PDT) (envelope-from dominic_marks@hotmail.com) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Wed, 2 May 2001 14:24:42 -0700 Received: from 194.72.9.37 by lw8fd.law8.hotmail.msn.com with HTTP; Wed, 02 May 2001 21:24:42 GMT X-Originating-IP: [194.72.9.37] From: "Dominic Marks" To: freebsd-hackers@freebsd.org Subject: KEvent doesnt return and KEvent sample troubles Date: Wed, 02 May 2001 21:24:42 -0000 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 02 May 2001 21:24:42.0455 (UTC) FILETIME=[4D52B670:01C0D34E] Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG I've been looking to start using the KEvent system and I've been experimenting with it. However I've been having several problems, with my own code as well as samples from http://www.flugsvamp.org. It appears I am able to create the correct structure's and register the events. However the event never returns and never responds to any action. For example if I use a sample which monitors the actions on a file I can read from, and write to the file and it shows no sign of noticing. I was wondering if it's simply a mistake of my own, however the failure for the samples I've found has puzzled my further. I'm working on a 4.3-STABLE machine using GCC version 2.95.3. Here is an example of code that I am using which doesn't seem to catch any events. Its a slightly modified version of read_test.c from flugsvamp.com which I edit so it would compile happily. It doesn't seem to work however. > #include #include #include #include #include #include #include #include #include #include #include main(int argc, char **argv) { int fd, kq, n; struct kevent event[1]; struct kevent *evp[1]; char buffer[128]; struct stat st; struct aiocb iocb; struct timespec ts = {0, 0}; if (argc != 2) errx(1, "Usage: %s file\n", argv[0]); fd = open(argv[1], O_RDONLY); if (fd < 0) err(1, "open: %s\n", argv[1]); lseek(fd, 0, SEEK_END); kq = syscall(SYS_kqueue); if (kq < 0) err(1, "kqueue"); event[0].ident = fd; event[0].filter = EVFILT_READ; event[0].flags = EV_ADD | EV_ENABLE; evp[0] = &event[0]; n = syscall(SYS_kevent, kq, 1, evp, 0, NULL, 0); for (;;) { n = syscall(SYS_kevent, kq, 0, NULL, 1, event, ts); if (n < 0) err(1, "kevent"); printf("kevent flags: 0x%x, data: 0x%x\n", event[0].flags, event[0].data); n = read(fd, buffer, 128); buffer[n] = '\0'; printf("%s", buffer); } } < I'd appreciate any feedback very much. Thank you Dominic Marks _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message