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/common/subprocess_unittest.cc b/common/subprocess_unittest.cc
index 104ef41..8dbaa0b 100644
--- a/common/subprocess_unittest.cc
+++ b/common/subprocess_unittest.cc
@@ -193,7 +193,7 @@
 TEST_F(SubprocessTest, SynchronousTrueSearchsOnPath) {
   int rc = -1;
   EXPECT_TRUE(Subprocess::SynchronousExecFlags(
-      {"true"}, Subprocess::kSearchPath, &rc, nullptr));
+      {"true"}, Subprocess::kSearchPath, &rc, nullptr, nullptr));
   EXPECT_EQ(0, rc);
 }
 
@@ -201,16 +201,17 @@
   vector<string> cmd = {
       kBinPath "/sh", "-c", "echo -n stdout-here; echo -n stderr-there >&2"};
   int rc = -1;
-  string stdout;
-  ASSERT_TRUE(Subprocess::SynchronousExec(cmd, &rc, &stdout));
+  string stdout, stderr;
+  ASSERT_TRUE(Subprocess::SynchronousExec(cmd, &rc, &stdout, &stderr));
   EXPECT_EQ(0, rc);
-  EXPECT_EQ("stdout-herestderr-there", stdout);
+  EXPECT_EQ("stdout-here", stdout);
+  EXPECT_EQ("stderr-there", stderr);
 }
 
 TEST_F(SubprocessTest, SynchronousEchoNoOutputTest) {
   int rc = -1;
   ASSERT_TRUE(Subprocess::SynchronousExec(
-      {kBinPath "/sh", "-c", "echo test"}, &rc, nullptr));
+      {kBinPath "/sh", "-c", "echo test"}, &rc, nullptr, nullptr));
   EXPECT_EQ(0, rc);
 }