To close the client socket fd, this patch sets O_CLOEXEC flag using fcntl().
Change-Id: I90f60c23ffc8aa0e62c93e26b4494493fb08eedb
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
}
ClientSocket::ClientSocket(int fd) : fd_(fd) {
+ SetCloseOnExec();
}
ClientSocket::~ClientSocket() {
Close();
}
+void ClientSocket::SetCloseOnExec() {
+ int flags = fcntl(fd_, F_GETFL, 0);
+ fcntl(fd_, F_SETFL, flags | O_CLOEXEC);
+ _I("Close on exec. fd(%d)", fd_);
+}
+
void ClientSocket::Close() {
if (fd_ > -1) {
close(fd_);
int GetFd() const;
int RemoveFd();
void SetNonblock();
+ void SetCloseOnExec();
private:
int fd_;
void ServerSocket::SetCloseOnExec() {
int flags = fcntl(fd_, F_GETFL, 0);
fcntl(fd_, F_SETFL, flags | O_CLOEXEC);
- _I("Close on exec");
+ _I("Close on exec. fd(%d)", fd_);
}
// LCOV_EXCL_STOP