enable SOCK_CLOEXEC explicit

leaking here means fork/vfork will duplicate fd without O_CLOEXEC flag
to the child process.

Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
This commit is contained in:
wanggang26 2023-11-24 10:44:50 +08:00 committed by Xiang Xiao
parent 3f0c9306d3
commit eab2cba4a1
20 changed files with 56 additions and 30 deletions

View file

@ -182,7 +182,7 @@ static inline bool net_connection(struct net_listener_s *nls)
printf("lo_listener: Accepting new connection on sd=%d\n",
nls->listensd);
sd = accept(nls->listensd, NULL, NULL);
sd = accept4(nls->listensd, NULL, NULL, SOCK_CLOEXEC);
if (sd < 0)
{
printf("lo_listener: accept failed: %d\n", errno);