Rename stdout and stderr to stdout_str and stderr_str
Support building with musl libc by not reusing the stdout and
stderr names, which are macros in musl.
Bug: 190084016
Test: m USE_HOST_MUSL=true host-native
Change-Id: Ia8093f42ede166c77c04f5524d442de836bde43c
diff --git a/common/subprocess.cc b/common/subprocess.cc
index 023017b..a0cb9a7 100644
--- a/common/subprocess.cc
+++ b/common/subprocess.cc
@@ -124,7 +124,7 @@
bool eof;
bool ok = utils::ReadAll(
record->stdout_fd, buf, base::size(buf), &bytes_read, &eof);
- record->stdout.append(buf, bytes_read);
+ record->stdout_str.append(buf, bytes_read);
if (!ok || eof) {
// There was either an error or an EOF condition, so we are done watching
// the file descriptor.
@@ -152,11 +152,11 @@
LOG(INFO) << "Subprocess exited with si_status: " << info.si_status;
}
- if (!record->stdout.empty()) {
- LOG(INFO) << "Subprocess output:\n" << record->stdout;
+ if (!record->stdout_str.empty()) {
+ LOG(INFO) << "Subprocess output:\n" << record->stdout_str;
}
if (!record->callback.is_null()) {
- record->callback.Run(info.si_status, record->stdout);
+ record->callback.Run(info.si_status, record->stdout_str);
}
// Release and close all the pipes after calling the callback so our
// redirected pipes are still alive. Releasing the process first makes
@@ -230,29 +230,30 @@
bool Subprocess::SynchronousExec(const vector<string>& cmd,
int* return_code,
- string* stdout,
- string* stderr) {
+ string* stdout_str,
+ string* stderr_str) {
// The default for |SynchronousExec| is to use |kSearchPath| since the code
// relies on that.
- return SynchronousExecFlags(cmd, kSearchPath, return_code, stdout, stderr);
+ return SynchronousExecFlags(
+ cmd, kSearchPath, return_code, stdout_str, stderr_str);
}
bool Subprocess::SynchronousExecFlags(const vector<string>& cmd,
uint32_t flags,
int* return_code,
- string* stdout,
- string* stderr) {
+ string* stdout_str,
+ string* stderr_str) {
brillo::ProcessImpl proc;
if (!LaunchProcess(cmd, flags, {STDERR_FILENO}, &proc)) {
LOG(ERROR) << "Failed to launch subprocess";
return false;
}
- if (stdout) {
- stdout->clear();
+ if (stdout_str) {
+ stdout_str->clear();
}
- if (stderr) {
- stderr->clear();
+ if (stderr_str) {
+ stderr_str->clear();
}
// Read from both stdout and stderr individually.
@@ -267,8 +268,8 @@
stdout_closed = true;
if (rc < 0)
PLOG(ERROR) << "Reading from child's stdout";
- } else if (stdout != nullptr) {
- stdout->append(buffer.data(), rc);
+ } else if (stdout_str != nullptr) {
+ stdout_str->append(buffer.data(), rc);
}
}
@@ -278,8 +279,8 @@
stderr_closed = true;
if (rc < 0)
PLOG(ERROR) << "Reading from child's stderr";
- } else if (stderr != nullptr) {
- stderr->append(buffer.data(), rc);
+ } else if (stderr_str != nullptr) {
+ stderr_str->append(buffer.data(), rc);
}
}
}
@@ -299,9 +300,9 @@
SubprocessRecord* record = pid_record.second.get();
// Make sure we read any remaining process output.
OnStdoutReady(record);
- if (!record->stdout.empty()) {
+ if (!record->stdout_str.empty()) {
LOG(INFO) << "Subprocess(" << pid_record.first << ") output:\n"
- << record->stdout;
+ << record->stdout_str;
}
}
}