first_stage_console: Fix execv() child error path
If the /first_stage.sh is not present on the system, the child process
which attempted to execv() ends up returning from the function along
with its parent, which can be seen in early logs e.g.
[ 10.747576][ T51] init: Attempting to run /first_stage.sh...
[ 10.757371][ T52] init: unable to execv /first_stage.sh, returned -1 errno 2
[ 10.767527][ T52] init: unable to execv, returned -1 errno 2
[...]
[ 10.789189][ T51] init: unable to execv, returned -1 errno 2
where both T51 and T52 end up executing the "rest" of StartConsole().
Instead, terminate the child if its execv() failed.
Test: run first_stage_init
Change-Id: I20bc0aeae627761a60fb2b55bae39871ad506f69
diff --git a/init/first_stage_console.cpp b/init/first_stage_console.cpp
index c6c3008..0076764 100644
--- a/init/first_stage_console.cpp
+++ b/init/first_stage_console.cpp
@@ -78,6 +78,7 @@
const char* args[] = {path, "/first_stage.sh", nullptr};
int rv = execv(path, const_cast<char**>(args));
LOG(ERROR) << "unable to execv /first_stage.sh, returned " << rv << " errno " << errno;
+ _exit(127);
}
namespace android {