To avoid inheriting fd to the child process, this patch sets close on
exec flag to fd.
Change-Id: I3ab2255e8cd80ad50ffbf355e51f0acec1030d68
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
namespace internal {
ServerSocket::ServerSocket(int fd) : fd_(fd) {
+ SetCloseOnExec();
}
ServerSocket::~ServerSocket() {
return 0;
}
+
+void ServerSocket::SetCloseOnExec() {
+ int flags = fcntl(fd_, F_GETFL, 0);
+ fcntl(fd_, F_SETFL, flags | O_CLOEXEC);
+ _I("Close on exec");
+}
// LCOV_EXCL_STOP
void ServerSocket::Close() {
int GetFd() const;
int Listen(int backlog);
void Close();
+ void SetCloseOnExec();
private:
int fd_;