]> xenbits.xensource.com Git - libvirt.git/commitdiff
Don't assume pid_t is the same size as an int
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 31 Oct 2012 17:00:50 +0000 (17:00 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 1 Nov 2012 09:16:04 +0000 (09:16 +0000)
virPidFileReadPathIfAlive passed in an 'int *' where a 'pid_t *'
was expected, which breaks on Mingw64 targets. Also a few places
were using '%d' for formatting pid_t, change them to '%lld' and
force a cast to the longer type as done elsewhere in the same
file.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/util/virpidfile.c
src/util/virprocess.c

index cb8a992a342ad3c1efc5c78e18dd6006779f2602..90a79c5e789b84210e6aaf7fe9d3e504a5f0f42f 100644 (file)
@@ -206,7 +206,7 @@ int virPidFileReadPathIfAlive(const char *path,
                               pid_t *pid,
                               const char *binPath)
 {
-    int ret, retPid;
+    int ret;
     bool isLink;
     char *procPath = NULL;
     char *procLink = NULL;
@@ -215,7 +215,7 @@ int virPidFileReadPathIfAlive(const char *path,
     char *resolvedProcLink = NULL;
     const char deletedText[] = " (deleted)";
     size_t deletedTextLen = strlen(deletedText);
-
+    pid_t retPid;
 
     /* only set this at the very end on success */
     *pid = -1;
index 4bb7ebc8ec5d0cbb2458b64401fcb2141295835a..f8a8a49b3e674a8ae5f63e8093d6b6de3fc6a4c2 100644 (file)
@@ -250,7 +250,7 @@ virProcessKillPainfully(pid_t pid, bool force)
     int i, ret = -1;
     const char *signame = "TERM";
 
-    VIR_DEBUG("vpid=%d force=%d", pid, force);
+    VIR_DEBUG("vpid=%lld force=%d", (long long)pid, force);
 
     /* This loop sends SIGTERM, then waits a few iterations (10 seconds)
      * to see if it dies. If the process still hasn't exited, and
@@ -265,8 +265,8 @@ virProcessKillPainfully(pid_t pid, bool force)
         if (i == 0) {
             signum = SIGTERM; /* kindly suggest it should exit */
         } else if ((i == 50) & force) {
-            VIR_DEBUG("Timed out waiting after SIGTERM to process %d, "
-                      "sending SIGKILL", pid);
+            VIR_DEBUG("Timed out waiting after SIGTERM to process %lld, "
+                      "sending SIGKILL", (long long)pid);
             /* No SIGKILL kill on Win32 ! Use SIGABRT instead which our
              * virProcessKill proc will handle more or less like SIGKILL */
 #ifdef WIN32
@@ -283,8 +283,8 @@ virProcessKillPainfully(pid_t pid, bool force)
         if (virProcessKill(pid, signum) < 0) {
             if (errno != ESRCH) {
                 virReportSystemError(errno,
-                                     _("Failed to terminate process %d with SIG%s"),
-                                     pid, signame);
+                                     _("Failed to terminate process %lld with SIG%s"),
+                                     (long long)pid, signame);
                 goto cleanup;
             }
             ret = signum == SIGTERM ? 0 : 1;
@@ -294,7 +294,8 @@ virProcessKillPainfully(pid_t pid, bool force)
         usleep(200 * 1000);
     }
 
-    VIR_DEBUG("Timed out waiting after SIGKILL to process %d", pid);
+    VIR_DEBUG("Timed out waiting after SIGKILL to process %lld",
+              (long long)pid);
 
 cleanup:
     return ret;