[libvirt] [PATCH] pid_t portability in virExec()

john.levon at sun.com john.levon at sun.com
Wed Dec 17 02:51:49 UTC 2008


# HG changeset patch
# User john.levon at sun.com
# Date 1229399267 28800
# Node ID 020f8b8e9340287a6ab3d869b359e39b905cd0ff
# Parent  1b81ac255ad765ab782829e7fe0a55dc7bab72ab
pid_t portability in virExec()

Use the right type for handling process IDs.

Signed-off-by: John Levon <john.levon at sun.com>

diff --git a/src/openvz_driver.c b/src/openvz_driver.c
--- a/src/openvz_driver.c
+++ b/src/openvz_driver.c
@@ -1093,7 +1093,8 @@ static char *openvzGetCapabilities(virCo
 
 static int openvzListDomains(virConnectPtr conn, int *ids, int nids) {
     int got = 0;
-    int veid, pid;
+    int veid;
+    pid_t pid;
     int outfd = -1;
     int errfd = -1;
     int ret;
@@ -1144,7 +1145,8 @@ static int openvzListDefinedDomains(virC
 static int openvzListDefinedDomains(virConnectPtr conn,
                                     char **const names, int nnames) {
     int got = 0;
-    int veid, pid, outfd = -1, errfd = -1, ret;
+    int veid, outfd = -1, errfd = -1, ret;
+    pid_t pid;
     char vpsname[32];
     char buf[32];
     char *endptr;
diff --git a/src/proxy_internal.c b/src/proxy_internal.c
--- a/src/proxy_internal.c
+++ b/src/proxy_internal.c
@@ -144,7 +144,8 @@ virProxyForkServer(void)
 virProxyForkServer(void)
 {
     const char *proxyPath = virProxyFindServerPath();
-    int ret, pid, status;
+    int ret, status;
+    pid_t pid;
     const char *proxyarg[2];
 
     if (!proxyPath) {
diff --git a/src/remote_internal.c b/src/remote_internal.c
--- a/src/remote_internal.c
+++ b/src/remote_internal.c
@@ -252,7 +252,8 @@ remoteForkDaemon(virConnectPtr conn)
 {
     const char *daemonPath = remoteFindDaemonPath();
     const char *const daemonargs[] = { daemonPath, "--timeout=30", NULL };
-    int ret, pid, status;
+    int ret, status;
+    pid_t pid;
 
     if (!daemonPath) {
         error(conn, VIR_ERR_INTERNAL_ERROR, _("failed to find libvirtd binary"));
diff --git a/src/storage_backend.c b/src/storage_backend.c
--- a/src/storage_backend.c
+++ b/src/storage_backend.c
@@ -411,7 +411,8 @@ virStorageBackendRunProgRegex(virConnect
                               void *data,
                               int *outexit)
 {
-    int child = 0, fd = -1, exitstatus, err, failed = 1;
+    int fd = -1, exitstatus, err, failed = 1;
+    pid_t child = 0;
     FILE *list = NULL;
     regex_t *reg;
     regmatch_t *vars = NULL;
@@ -575,7 +576,8 @@ virStorageBackendRunProgNul(virConnectPt
                             void *data)
 {
     size_t n_tok = 0;
-    int child = 0, fd = -1, exitstatus;
+    int fd = -1, exitstatus;
+    pid_t child = 0;
     FILE *fp = NULL;
     char **v;
     int err = -1;
diff --git a/src/uml_driver.c b/src/uml_driver.c
--- a/src/uml_driver.c
+++ b/src/uml_driver.c
@@ -711,7 +711,8 @@ static int umlStartVMDaemon(virConnectPt
                             virDomainObjPtr vm) {
     const char **argv = NULL, **tmp;
     const char **progenv = NULL;
-    int i, ret, pid;
+    int i, ret;
+    pid_t pid;
     char *logfile;
     int logfd = -1;
     struct stat sb;
diff --git a/src/util.c b/src/util.c
--- a/src/util.c
+++ b/src/util.c
@@ -182,10 +182,11 @@ __virExec(virConnectPtr conn,
           const char *const*argv,
           const char *const*envp,
           const fd_set *keepfd,
-          int *retpid,
+          pid_t *retpid,
           int infd, int *outfd, int *errfd,
           int flags) {
-    int pid, null, i, openmax;
+    pid_t pid;
+    int null, i, openmax;
     int pipeout[2] = {-1,-1};
     int pipeerr[2] = {-1,-1};
     int childout = -1;
@@ -439,7 +440,7 @@ virExec(virConnectPtr conn,
         const char *const*argv,
         const char *const*envp,
         const fd_set *keepfd,
-        int *retpid,
+        pid_t *retpid,
         int infd, int *outfd, int *errfd,
         int flags) {
     char *argv_str;
@@ -554,7 +555,8 @@ virRun(virConnectPtr conn,
 virRun(virConnectPtr conn,
        const char *const*argv,
        int *status) {
-    int childpid, exitstatus, execret, waitret;
+    pid_t childpid;
+    int exitstatus, execret, waitret;
     int ret = -1;
     int errfd = -1, outfd = -1;
     char *outbuf = NULL;
diff --git a/src/util.h b/src/util.h
--- a/src/util.h
+++ b/src/util.h
@@ -27,6 +27,7 @@
 
 #include "verify.h"
 #include <sys/select.h>
+#include <sys/types.h>
 
 int saferead(int fd, void *buf, size_t count);
 ssize_t safewrite(int fd, const void *buf, size_t count);
@@ -41,7 +42,7 @@ int virExec(virConnectPtr conn,
             const char *const*argv,
             const char *const*envp,
             const fd_set *keepfd,
-            int *retpid,
+            pid_t *retpid,
             int infd,
             int *outfd,
             int *errfd,




More information about the libvir-list mailing list