From: Hwankyu Jhun Date: Tue, 12 Sep 2023 06:58:44 +0000 (+0900) Subject: Set close on exec flag X-Git-Tag: accepted/tizen/6.0/unified/20230913.040037~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=94e5e3188316cd044a5e73b6a9a012382d54c9c8;p=platform%2Fcore%2Fappfw%2Frpc-port.git Set close on exec flag 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 --- diff --git a/src/port-internal.cc b/src/port-internal.cc index 9eb50ec..d553ce0 100644 --- a/src/port-internal.cc +++ b/src/port-internal.cc @@ -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) diff --git a/src/port-internal.h b/src/port-internal.h index 98c9b2f..730e8ec 100644 --- a/src/port-internal.h +++ b/src/port-internal.h @@ -66,6 +66,7 @@ class Port : public std::enable_shared_from_this { } private: + void SetCloseOnExec(); void IgnoreIOEvent(); int ListenIOEvent();