Set close on exec flag 60/298660/1
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 12 Sep 2023 06:58:44 +0000 (15:58 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 12 Sep 2023 06:58:44 +0000 (15:58 +0900)
To close the file descriptor when calling the execv(), this patch sets
the O_CLOEXEC flag to the file descriptor.

Change-Id: Ibd4bcdacdd40f0e5f207518428c91fa6796465c9
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/port-internal.cc
src/port-internal.h

index 9eb50ec..d553ce0 100644 (file)
@@ -79,6 +79,12 @@ Port::~Port() {
   close(fd_);
 }
 
+void Port::SetCloseOnExec() {
+  int flags = fcntl(fd_, F_GETFL, 0);
+  fcntl(fd_, F_SETFL, flags | O_CLOEXEC);
+  _W("Close on exec. fd(%d)", fd_);
+}
+
 int Port::SetPrivateSharing(const char* paths[], unsigned int size) {
   int ret = aul_rpc_port_set_private_sharing(id_.c_str(), paths, size);
   if (ret != 0)
index 98c9b2f..730e8ec 100644 (file)
@@ -66,6 +66,7 @@ class Port : public std::enable_shared_from_this<Port> {
   }
 
  private:
+  void SetCloseOnExec();
   void IgnoreIOEvent();
   int ListenIOEvent();