     f inotify-task <input-task> ;
 
 : init-inotify ( mx -- )
-    <inotify>
-    dup inotify set-global
+    <inotify> dup inotify set-global
     <inotify-task> swap register-io-task ;
 
 M: inotify-task do-io-task ( task -- )

    dup simple-monitor-handle watches delete-at
    simple-monitor-handle inotify-fd swap inotify_rm_watch io-error ;

M: linux-io <monitor> ( path recursive? -- monitor )
    drop IN_CHANGE_EVENTS add-watch ;

M: linux-monitor dispose ( monitor -- )


: wd>monitor ( wd -- monitor ) watches at ;

: <inotify> ( -- port/f )
    H{ } clone
    inotify_init dup 0 < [ 2drop f ] [
        inotify <buffered-port>
        { set-inotify-watches set-delegate } inotify construct
    ] if ;

: inotify-fd inotify get-global port-handle ;

