inotify and recursion

Artur Skawina art.08.09 at gmail.com
Fri Dec 27 02:50:24 PST 2013


On 12/27/13 04:23, David Eagen wrote:
> void main()
> {
>     string filename="aaa";
> 
>     int inotfd = inotify_init();
>     int watch_desc = inotify_add_watch(inotfd, toStringz(filename), IN_MODIFY);
> 
>     size_t bufsiz = inotify_event.sizeof + PATH_MAX + 1;
>     inotify_event* event = cast(inotify_event *) malloc(bufsiz);
> 
>     /* wait for an event to occur */
>     read(inotfd, event, event.sizeof);

You probably meant

   read(inotfd, event, (*event).sizeof);

but in this case the inotify_event structure contains an optional
trailing buffer, so it should be

   read(inotfd, event, bufsiz);

artur


More information about the Digitalmars-d-learn mailing list