update_engine: pipe stderr individually in SycnronousExec

Currently, SyncronousExec pipes stderr to stdout which is fine but not
ideal. Specially we have an issue with vpd_get_value script that exits
with 0 even with underlying failures. This is problematic, because we
get the combined stdout/stderr of the command and since the exit code is
0 we assume the output is correct. Then, we create the XML request based
on this output but with stderr combined (too much junk) as the value of
an XML attribute. This causes update failure. Fortunately, vpd_get_value
correctly separates its children's stderr and stdout. So as long as we
don't combine both stdout and stderr into one stream, this error wil not
happen again anymore.

Also a few other nitpicks in this CL:
- Constructing the command for shutdown using simpler syntax.
- Logging the command before running it for all external subprocess runs.

BUG=chromium:1010306
TEST=sudo FEATURES=test emerge update_engine

Change-Id: Ia620afed814e4fe9ba24b1a0ad01680481c6ba7c
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/1901886
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Andrew Lassalle <lassalle@chromium.org>
Reviewed-by: Jae Hoon Kim <kimjae@chromium.org>
Commit-Queue: Amin Hassani <ahassani@chromium.org>
diff --git a/payload_generator/squashfs_filesystem.cc b/payload_generator/squashfs_filesystem.cc
index e43bc0a..9838794 100644
--- a/payload_generator/squashfs_filesystem.cc
+++ b/payload_generator/squashfs_filesystem.cc
@@ -81,12 +81,12 @@
   // Run unsquashfs to get the system file map.
   // unsquashfs -m <map-file> <squashfs-file>
   vector<string> cmd = {"unsquashfs", "-m", map_file, sqfs_path};
-  string stdout;
+  string stdout, stderr;
   int exit_code;
-  if (!Subprocess::SynchronousExec(cmd, &exit_code, &stdout) ||
+  if (!Subprocess::SynchronousExec(cmd, &exit_code, &stdout, &stderr) ||
       exit_code != 0) {
-    LOG(ERROR) << "Failed to run unsquashfs -m. The stdout content was: "
-               << stdout;
+    LOG(ERROR) << "Failed to run `unsquashfs -m` with stdout content: "
+               << stdout << " and stderr content: " << stderr;
     return false;
   }
   TEST_AND_RETURN_FALSE(utils::ReadFile(map_file, map));
@@ -109,10 +109,12 @@
                         unsquash_dir.GetPath().value(),
                         sqfs_path,
                         kUpdateEngineConf};
+  string stdout, stderr;
   int exit_code;
-  if (!Subprocess::SynchronousExec(cmd, &exit_code, nullptr) ||
+  if (!Subprocess::SynchronousExec(cmd, &exit_code, &stdout, &stderr) ||
       exit_code != 0) {
-    PLOG(ERROR) << "Failed to unsquashfs etc/update_engine.conf: ";
+    PLOG(ERROR) << "Failed to unsquashfs etc/update_engine.conf with stdout: "
+                << stdout << " and stderr: " << stderr;
     return false;
   }