diff options
author | Rajeev Kumar <rajekumar@google.com> | 2018-01-24 16:38:38 -0800 |
---|---|---|
committer | Rajeev Kumar <rajekumar@google.com> | 2018-01-24 16:40:07 -0800 |
commit | e67304afabcb500bd59fa6c6d525ffe31273afa6 (patch) | |
tree | 5da44cc9e6440ac73d066c05c1d74aaad37bfbd1 /alloc-stress | |
parent | 218c1b4255b89fcac1091973b7e8d5dfafecc98d (diff) | |
download | extras-e67304afabcb500bd59fa6c6d525ffe31273afa6.tar.gz |
Use executable path if available while calling execl
Without this change calling alloc-stress from root dir fails with
following error:
pid: 22755 adj: 1000 sz: 0
createProcess( 22756):125 condition:0 failed
Test: Manual
Change-Id: Iacf29728ad01374aa3d64472d17a5d13a3014c88
Diffstat (limited to 'alloc-stress')
-rw-r--r-- | alloc-stress/alloc-stress.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/alloc-stress/alloc-stress.cpp b/alloc-stress/alloc-stress.cpp index 03cb655c..fcb074b6 100644 --- a/alloc-stress/alloc-stress.cpp +++ b/alloc-stress/alloc-stress.cpp @@ -120,7 +120,11 @@ pid_t createProcess(Pipe pipe, const char *exName, char writeFdStr[16]; snprintf(readFdStr, sizeof(readFdStr), "%d", pipe.getReadFd()); snprintf(writeFdStr, sizeof(writeFdStr), "%d", pipe.getWriteFd()); - execl(exName, exName, "--worker", arg, readFdStr, writeFdStr, + char exPath[PATH_MAX]; + ssize_t exPathLen = readlink("/proc/self/exe", exPath, sizeof(exPath)); + bool isExPathAvailable = + exPathLen != -1 && exPathLen < static_cast<ssize_t>(sizeof(exPath)); + execl(isExPathAvailable ? exPath : exName, exName, "--worker", arg, readFdStr, writeFdStr, use_memcg ? "1" : "0", nullptr); ASSERT_TRUE(0); } |