Re: [PATCH 3/5] Introduce functions for checking whether a pidfile is valid

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@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?

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 :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]