summaryrefslogtreecommitdiffstats
path: root/cmds
diff options
context:
space:
mode:
authord34d <clark@cyngn.com>2015-10-28 18:35:09 -0700
committerd34d <clark@cyngn.com>2015-10-28 18:35:09 -0700
commit716c2cf34abd1df52210cb0aca6003b4d444a7ac (patch)
treee2a09cd46b53d359935d4faa988ba0837ca9f07a /cmds
parent66a1d0d715c0f3421d44a2556c3368ed75809b59 (diff)
downloadframeworks_native-716c2cf34abd1df52210cb0aca6003b4d444a7ac.zip
frameworks_native-716c2cf34abd1df52210cb0aca6003b4d444a7ac.tar.gz
frameworks_native-716c2cf34abd1df52210cb0aca6003b4d444a7ac.tar.bz2
installd: Call pipe() before forking
Change-Id: Ideef9387c503a25dadb2afb4e4b394a2e61cd8e9
Diffstat (limited to 'cmds')
-rw-r--r--cmds/installd/commands.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/cmds/installd/commands.cpp b/cmds/installd/commands.cpp
index 3b8cc0e..cf54598 100644
--- a/cmds/installd/commands.cpp
+++ b/cmds/installd/commands.cpp
@@ -1744,8 +1744,7 @@ static void run_aapt(const char *source_apk, const char *internal_path,
int aapt(const char *source_apk, const char *internal_path, const char *out_restable, uid_t uid,
int pkgId, int min_sdk_version, const char *common_res_path)
{
- ALOGD("aapt source_apk=%s internal_path=%s out_restable=%s uid=%d, pkgId=%d, \
- min_sdk_version=%d, common_res_path=%s",
+ ALOGD("aapt source_apk=%s internal_path=%s out_restable=%s uid=%d, pkgId=%d,min_sdk_version=%d, common_res_path=%s",
source_apk, internal_path, out_restable, uid, pkgId, min_sdk_version, common_res_path);
static const int PARENT_READ_PIPE = 0;
static const int CHILD_WRITE_PIPE = 1;
@@ -1754,7 +1753,12 @@ int aapt(const char *source_apk, const char *internal_path, const char *out_rest
char restable_path[PATH_MAX];
char resapk_path[PATH_MAX];
+ // create pipes for redirecting STDERR to a buffer that can be displayed in logcat
int pipefd[2];
+ if (pipe(pipefd) != 0) {
+ pipefd[0] = pipefd[1] = -1;
+ }
+
pid_t pid = fork();
// get file descriptor for resources.arsc
@@ -1778,9 +1782,6 @@ int aapt(const char *source_apk, const char *internal_path, const char *out_rest
goto fail;
}
- if (pipe(pipefd) != 0) {
- pipefd[0] = pipefd[1] = -1;
- }
if (pid == 0) {
/* child -- drop privileges before continuing */
if (setgid(uid) != 0) {