Richard W.M. Jones wrote:
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.
...
Subject: [PATCH] Set LC_ALL=C before running qemu.
This looks fine.
One possible improvement.
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);
Failure is unlikely, but you might want to diagnose it, just in case.
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) {