Skip to content

Commit b3013f9

Browse files
author
Artiom N.
committed
Chapter 25 helper add
1 parent 11a5720 commit b3013f9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env python3
2+
3+
import fcntl
4+
5+
6+
def set_close_exec(fd):
7+
"""
8+
Helper to set CLOEXEC.
9+
10+
:fd: int file descriptor
11+
"""
12+
flags = fcntl.fcntl(fd, fcntl.F_GETFD)
13+
fcntl.fcntl(fd, fcntl.F_SETFD, flags | fcntl.FD_CLOEXEC)

0 commit comments

Comments
 (0)