Jump to content
  • Advertisement
Sign in to follow this  

kqueue-problem

This topic is 4736 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I wrote this function, which is supposed to poll a directory for new files. But when i execute it with await_write("testdir"); the first call to kevent returns -1 and sets errno to "No such file or directory" I have no idea what I'm doing wrong and i was hoping somebody here could help.
int await_write(char* dir)
{
  struct kevent kev;
  struct kevent retkev;
  DIR* dirp;
  int kq;
  int n;
  int dirdes;

  if((dirp = opendir(dir)) == NULL) {
    printf("failed to open directory.\n");
    return -1;
  }
  dirdes = dirfd(dirp);

  EV_SET(&kev, dirdes, EVFILT_VNODE, EV_ONESHOT, NOTE_WRITE, 0, NULL);
  kq = kqueue();

  if((n = kevent(kq, &kev, 1, NULL, 0, NULL)) == -1) {
    perror("kevent");
    return -1;
  }
  kevent(kq, NULL, 0, &retkev, 1, NULL);

  return 0;
}


[Edited by - branhield on June 2, 2005 7:09:09 AM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!