[PATCH] Don't assume pid_t is the same size as an int

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

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

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@xxxxxxxxxx>
---
 src/util/virpidfile.c |  4 ++--
 src/util/virprocess.c | 13 +++++++------
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c
index cb8a992..90a79c5 100644
--- a/src/util/virpidfile.c
+++ b/src/util/virpidfile.c
@@ -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;
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index 4bb7ebc..f8a8a49 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -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;
-- 
1.7.11.7

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