aboutsummaryrefslogtreecommitdiff
path: root/chromeos
diff options
context:
space:
mode:
authorAlex Deymo <deymo@chromium.org>2015-07-27 13:32:55 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-07-29 08:45:40 +0000
commitd78ff4245b2fd21aa6a88b0890fa1db73c6a5326 (patch)
tree1bc3c7287cb06c6c04930f139e105354b4f4274a /chromeos
parent7dfa3acb15d11239454fbee7c783ec427a171072 (diff)
downloadlibbrillo-d78ff4245b2fd21aa6a88b0890fa1db73c6a5326.tar.gz
libchromeos: Prevent closing known bad fd in Process class.
When using ProcessImpl::BindFd the parent_fd is set to -1. This causes the process to call close(-1) which will silently fail. This patch avoids calling close on the parent_fd when it is -1 so we don't issue a known bad call to close. This makes it easier to debug problems when running such program with strace. BUG=None TEST=Unittests still pass. Change-Id: I3a69fca21a4ba4a5911897b13a95bdeffd53d3cf Reviewed-on: https://chromium-review.googlesource.com/288782 Trybot-Ready: Alex Deymo <deymo@chromium.org> Tested-by: Alex Deymo <deymo@chromium.org> Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Alex Deymo <deymo@chromium.org>
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/process.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/chromeos/process.cc b/chromeos/process.cc
index 650d3d3..43b9fbd 100644
--- a/chromeos/process.cc
+++ b/chromeos/process.cc
@@ -175,7 +175,8 @@ bool ProcessImpl::Start() {
// Close parent's side of the child pipes. dup2 ours into place and
// then close our ends.
for (PipeMap::iterator i = pipe_map_.begin(); i != pipe_map_.end(); ++i) {
- IGNORE_EINTR(close(i->second.parent_fd_));
+ if (i->second.parent_fd_ != -1)
+ IGNORE_EINTR(close(i->second.parent_fd_));
HANDLE_EINTR(dup2(i->second.child_fd_, i->first));
}
// Defer the actual close() of the child fd until afterward; this lets the