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

[Libguestfs] [PATCH] Set LC_ALL=C before running qemu.



This patch by no means covers all the cases where we run external
programs and expect to parse their output without setting LC_ALL=C.
But it's a good start.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming blog: http://rwmj.wordpress.com
Fedora now supports 80 OCaml packages (the OPEN alternative to F#)
http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
>From 48d1aac55e4d44c37512937d64d0d76b3910f8e2 Mon Sep 17 00:00:00 2001
From: Richard Jones <rjones redhat com>
Date: Wed, 21 Oct 2009 16:31:26 +0100
Subject: [PATCH] Set LC_ALL=C before running qemu.

---
 src/guestfs.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/guestfs.c b/src/guestfs.c
index e49f57a..a25e9e7 100644
--- a/src/guestfs.c
+++ b/src/guestfs.c
@@ -1195,6 +1195,8 @@ guestfs__launch (guestfs_h *g)
     setpgid (0, 0);
 #endif
 
+    setenv ("LC_ALL", "C", 1);
+
     execv (g->qemu, g->cmdline); /* Run qemu. */
     perror (g->qemu);
     _exit (1);
@@ -1486,7 +1488,7 @@ test_qemu (guestfs_h *g)
   g->qemu_help = NULL;
   g->qemu_version = NULL;
 
-  snprintf (cmd, sizeof cmd, "'%s' -help", g->qemu);
+  snprintf (cmd, sizeof cmd, "LC_ALL=C '%s' -help", g->qemu);
 
   fp = popen (cmd, "r");
   /* qemu -help should always work (qemu -version OTOH wasn't
@@ -1508,7 +1510,7 @@ test_qemu (guestfs_h *g)
   if (pclose (fp) == -1)
     goto error;
 
-  snprintf (cmd, sizeof cmd, "'%s' -version 2>/dev/null", g->qemu);
+  snprintf (cmd, sizeof cmd, "LC_ALL=C '%s' -version 2>/dev/null", g->qemu);
 
   fp = popen (cmd, "r");
   if (fp) {
-- 
1.6.5.rc2


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