ソースを参照

set SOCK_CLOEXEC (#268)

Co-authored-by: 管培喆 <guanpeizhe@minieye.cc>
MrSen 3 年 前
コミット
158cff2fce
1 ファイル変更4 行追加0 行削除
  1. 4 0
      base/hsocket.c

+ 4 - 0
base/hsocket.c

@@ -266,7 +266,11 @@ int Bind(int port, const char* host, int type) {
 }
 
 int Listen(int port, const char* host) {
+#ifdef OS_LINUX
+    int sockfd = Bind(port, host, SOCK_STREAM|SOCK_CLOEXEC);
+#else
     int sockfd = Bind(port, host, SOCK_STREAM);
+#endif
     if (sockfd < 0) return sockfd;
     return ListenFD(sockfd);
 }