sustrik / libdill

Structured concurrency in C
MIT License
1.68k stars 156 forks source link

Set close-on-exec flagas to avoid FD leaks to subprocesses #220

Open jcarrano opened 1 year ago

jcarrano commented 1 year ago

Description

These fixes prevent file descriptor leaks in my application. There may still be other potential leak sources in functions that my application does not use.

I tried to implement accept() using accept4() if it is available since that avoids a potential race condition. Same with fcntl(n,F_DUPFD_CLOEXEC,0) instead of dup().