On 08/12/2011 08:07 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange"<berrange@xxxxxxxxxx> 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?
-- Eric Blake eblake@xxxxxxxxxx +1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list