On Wed, Aug 17, 2011 at 11:34:34AM -0600, Eric Blake wrote:
On 08/12/2011 08:07 AM, Daniel P. Berrange wrote:
>From: "Daniel P. Berrange"<berrange(a)redhat.com>
>
>In some cases the caller of virPidFileRead might like extra checks
>to determine whether the pid just read is really the one they are
>expecting. This adds virPidFileReadIfAlive which will check whether
>the pid is still alive with kill(0, -1), and (on linux only) will
>look at /proc/$PID/path
>
>+ * Returns -errno upon error, or zero on successful
>+ * reading of the pidfile. If the PID was not still
>+ * alive, zero will be returned, but @pid will be
>+ * set to -1.
>+ */
>+int virPidFileReadPathIfAlive(const char *path,
>+ pid_t *pid,
>+ const char *binpath)
>+{
>+ int rc;
>+ char *procpath = NULL;
>+
>+ rc = virPidFileReadPath(path, pid);
>+ if (rc< 0)
>+ return rc;
>+
>+ /* Check that it's still alive */
>+ if (kill(*pid, 0)< 0) {
>+ *pid = -1;
>+ return 0;
>+ }
This fails to compile on mingw, which lacks kill(). What's the best
approach to fixing this, always fail with -ENOSYS, since right now
we aren't making any use of pid files on mingw builds anyway?
We already skip the /proc check on non-Linux. So I say we just skip
the kill call on Win32. This stuff is only an extra sanity check
upon loading the pidfile, so I think returning an error is too
mean and we just skip the kill check, or write a win32 specific
check for process ID.
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|