[M120 Migration][VD] Increase buffer size of cmd line for child process 52/308252/1
authorjie <jie137.zhang@samsung.com>
Mon, 18 Mar 2024 06:42:36 +0000 (14:42 +0800)
committerJie Zhang <jie137.zhang@samsung.com>
Wed, 20 Mar 2024 07:54:56 +0000 (07:54 +0000)
On TV product, kdbus connecting was failed because saved size of command
line in kernel and actual size were different. So we need to increase
buffer size of command line when zygote process is executed by execvp().
This patch appends dummy argument once calling execvp().

Reference:
  - https://review.tizen.org/gerrit/#/c/291592/

Change-Id: I9da3f12b2a464c2598012541f720fa0ff15a043b
Signed-off-by: jie <jie137.zhang@samsung.com>
(cherry picked from commit d33bf9d2b81e6040f60f7789c40fa41cdc660531)

base/process/launch_posix.cc

index b249686..75eb17b 100644 (file)
@@ -70,6 +70,10 @@ namespace base {
 
 namespace {
 
+#if BUILDFLAG(IS_TIZEN_TV)
+static const size_t kDummyArgLength = 2048;
+#endif
+
 // Get the process's "environment" (i.e. the thing that setenv/getenv
 // work with).
 char** GetEnvironment() {
@@ -289,10 +293,24 @@ Process LaunchProcess(const std::vector<std::string>& argv,
   fd_shuffle2.reserve(options.fds_to_remap.size());
 
   std::vector<char*> argv_cstr;
+#if BUILDFLAG(IS_TIZEN_TV)
+  argv_cstr.reserve(argv.size() + 2);
+#else
   argv_cstr.reserve(argv.size() + 1);
+#endif
   for (const auto& arg : argv)
     argv_cstr.push_back(const_cast<char*>(arg.c_str()));
+#if BUILDFLAG(IS_TIZEN_TV)
+  // Append dummy argument in order to increase buffer size of command line
+  // for forked process from launched process.
+  char dummy_arg[kDummyArgLength];
+  memset(dummy_arg, ' ', kDummyArgLength);
+  dummy_arg[kDummyArgLength - 1] = '\0';
+  argv_cstr.push_back(dummy_arg);
   argv_cstr.push_back(nullptr);
+#else
+  argv_cstr.push_back(nullptr);
+#endif
 
   std::unique_ptr<char* []> new_environ;
   char* const empty_environ = nullptr;