Created
April 14, 2015 16:40
-
-
Save javiermon/1a08e14b2e972065c79e to your computer and use it in GitHub Desktop.
set CLOEXEC flag on socket
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import fcntl | |
| def set_close_exec(fd): | |
| """ | |
| Helper to add CLOEXEC to provided file descriptor. | |
| :param fd: int | |
| """ | |
| flags = fcntl.fcntl(fd, fcntl.F_GETFD) | |
| fcntl.fcntl(fd, fcntl.F_SETFD, flags | fcntl.FD_CLOEXEC) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment