Stat changes not picked up on MacOSX 10.5.

Graham Leggett minfrin at
Tue Oct 28 12:38:33 CET 2008

Hi all,

Using the code below, I am expecting the event loop to run the callback 
when I touch or edit the file to which I am pointing 
(directorry->directory), but for some reason this doesn't happen.

The timeout does work however.

Can anyone tell me if I am doing something stupid, or whether there are 
known problems with MacOSX 10.5?

static void watch_directory_cb(struct ev_loop *loop, ev_stat *w, int 
revents) {
// we never reach here
         if (w->attr.st_nlink) {
                 printf("passwd current size  %ld\n", (long) 
                 printf("passwd current atime %ld\n", (long) 
                 printf("passwd current mtime %ld\n", (long) 
         } else
                 /* you shalt not abuse printf for puts */
                 puts("directory does not exist.\n");

// another callback, this time for a time-out
static void
watch_timeout_cb (EV_P_ struct ev_timer *w, int revents)
         puts ("timeout");
         // this causes the innermost ev_loop to stop iterating
         ev_unloop (EV_A_ EVUNLOOP_ONE);

The code:

         ev_stat directory_watcher;
         ev_timer timeout_watcher;

                 directory->loop = ev_loop_new(0);

                 /* initialise an io watcher, then start it */
                 ev_stat_init(&directory_watcher, watch_directory_cb,
                                 directory->directory, 0.);
                 ev_stat_start(directory->loop, &directory_watcher);

                 /* initialise a timer watcher, then start it */
                 ev_timer_init(&timeout_watcher, watch_timeout_cb, 
                 ev_timer_start(directory->loop, &timeout_watcher);

                 /* now wait for events to arrive */
                 ev_loop(directory->loop, 0);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3287 bytes
Desc: S/MIME Cryptographic Signature
URL: <>

More information about the libev mailing list