+<h2 id="code_ev_stat_code_did_the_file_attri"><code>ev_stat</code> - did the file attributes just change?</h2>
+<div id="code_ev_stat_code_did_the_file_attri-2">
+<p>This watches a filesystem path for attribute changes. That is, it calls
+<code>stat</code> regularly (or when the OS says it changed) and sees if it changed
+compared to the last time, invoking the callback if it did.</p>
+<p>The path does not need to exist: changing from "path exists" to "path does
+not exist" is a status change like any other. The condition "path does
+not exist" is signified by the <code>st_nlink</code> field being zero (which is
+otherwise always forced to be at least one) and all the other fields of
+the stat buffer having unspecified contents.</p>
+<p>The path <i>should</i> be absolute and <i>must not</i> end in a slash. If it is
+relative and your working directory changes, the behaviour is undefined.</p>
+<p>Since there is no standard to do this, the portable implementation simply
+calls <code>stat (2)</code> regularly on the path to see if it changed somehow. You
+can specify a recommended polling interval for this case. If you specify
+a polling interval of <code>0</code> (highly recommended!) then a <i>suitable,
+unspecified default</i> value will be used (which you can expect to be around
+five seconds, although this might change dynamically). Libev will also
+impose a minimum interval which is currently around <code>0.1</code>, but thats
+usually overkill.</p>
+<p>This watcher type is not meant for massive numbers of stat watchers,
+as even with OS-supported change notifications, this can be
+resource-intensive.</p>
+<p>At the time of this writing, only the Linux inotify interface is
+implemented (implementing kqueue support is left as an exercise for the
+reader). Inotify will be used to give hints only and should not change the
+semantics of <code>ev_stat</code> watchers, which means that libev sometimes needs
+to fall back to regular polling again even with inotify, but changes are
+usually detected immediately, and if the file exists there will be no
+polling.</p>
+<dl>
+ <dt>ev_stat_init (ev_stat *, callback, const char *path, ev_tstamp interval)</dt>
+ <dt>ev_stat_set (ev_stat *, const char *path, ev_tstamp interval)</dt>
+ <dd>
+ <p>Configures the watcher to wait for status changes of the given
+<code>path</code>. The <code>interval</code> is a hint on how quickly a change is expected to
+be detected and should normally be specified as <code>0</code> to let libev choose
+a suitable value. The memory pointed to by <code>path</code> must point to the same
+path for as long as the watcher is active.</p>
+ <p>The callback will be receive <code>EV_STAT</code> when a change was detected,
+relative to the attributes at the time the watcher was started (or the
+last change was detected).</p>
+ </dd>
+ <dt>ev_stat_stat (ev_stat *)</dt>
+ <dd>
+ <p>Updates the stat buffer immediately with new values. If you change the
+watched path in your callback, you could call this fucntion to avoid
+detecting this change (while introducing a race condition). Can also be
+useful simply to find out the new values.</p>
+ </dd>
+ <dt>ev_statdata attr [read-only]</dt>
+ <dd>
+ <p>The most-recently detected attributes of the file. Although the type is of
+<code>ev_statdata</code>, this is usually the (or one of the) <code>struct stat</code> types
+suitable for your system. If the <code>st_nlink</code> member is <code>0</code>, then there
+was some error while <code>stat</code>ing the file.</p>
+ </dd>
+ <dt>ev_statdata prev [read-only]</dt>
+ <dd>
+ <p>The previous attributes of the file. The callback gets invoked whenever
+<code>prev</code> != <code>attr</code>.</p>
+ </dd>
+ <dt>ev_tstamp interval [read-only]</dt>
+ <dd>
+ <p>The specified interval.</p>
+ </dd>
+ <dt>const char *path [read-only]</dt>
+ <dd>
+ <p>The filesystem path that is being watched.</p>
+ </dd>
+</dl>
+<p>Example: Watch <code>/etc/passwd</code> for attribute changes.</p>
+<pre> static void
+ passwd_cb (struct ev_loop *loop, ev_stat *w, int revents)
+ {
+ /* /etc/passwd changed in some way */
+ if (w->attr.st_nlink)
+ {
+ printf ("passwd current size %ld\n", (long)w->attr.st_size);
+ printf ("passwd current atime %ld\n", (long)w->attr.st_mtime);
+ printf ("passwd current mtime %ld\n", (long)w->attr.st_mtime);
+ }
+ else
+ /* you shalt not abuse printf for puts */
+ puts ("wow, /etc/passwd is not there, expect problems. "
+ "if this is windows, they already arrived\n");
+ }
+
+ ...
+ ev_stat passwd;
+
+ ev_stat_init (&passwd, passwd_cb, "/etc/passwd");
+ ev_stat_start (loop, &passwd);
+
+
+
+
+</pre>
+
+</div>
+<h2 id="code_ev_idle_code_when_you_ve_got_no"><code>ev_idle</code> - when you've got nothing better to do...</h2>