From 10cd48da1d1c5c63e9e890c872aecc7160122f71 Mon Sep 17 00:00:00 2001 From: Matthew Bouyack Date: Tue, 20 Sep 2016 19:08:42 -0700 Subject: Fail gracefully when we fail to fork the update binary This change was original made in cw-f-dev but caused failures in nyc-mr1-dev-plus-aosp due to lack of support for 'LOGE' This version of the change uses the new 'LOG(ERROR)' style logging instead. See bug b/31395655 Test: attempt a memory intensive incremental OTA on a low-memory device Change-Id: Ia87d989a66b0ce3f48e862abf9b9d6943f70e554 (cherry picked from commit c8db4817809e163d887f7955a03ad0f97159f12b) --- install.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/install.cpp b/install.cpp index 98f1e3f36..f124a2688 100644 --- a/install.cpp +++ b/install.cpp @@ -373,6 +373,14 @@ try_update_binary(const char* path, ZipArchiveHandle zip, bool* wipe_cache, } pid_t pid = fork(); + + if (pid == -1) { + close(pipefd[0]); + close(pipefd[1]); + PLOG(ERROR) << "Failed to fork update binary"; + return INSTALL_ERROR; + } + if (pid == 0) { umask(022); close(pipefd[0]); -- cgit v1.2.3