Revision 73027ed2 lib/utils.py
b/lib/utils.py | ||
---|---|---|
273 | 273 |
return status |
274 | 274 |
|
275 | 275 |
|
276 |
def SetCloseOnExecFlag(fd, enable): |
|
277 |
"""Sets or unsets the close-on-exec flag on a file descriptor. |
|
278 |
|
|
279 |
@type fd: int |
|
280 |
@param fd: File descriptor |
|
281 |
@type enable: bool |
|
282 |
@param enable: Whether to set or unset it. |
|
283 |
|
|
284 |
""" |
|
285 |
flags = fcntl.fcntl(fd, fcntl.F_GETFD) |
|
286 |
|
|
287 |
if enable: |
|
288 |
flags |= fcntl.FD_CLOEXEC |
|
289 |
else: |
|
290 |
flags &= ~fcntl.FD_CLOEXEC |
|
291 |
|
|
292 |
fcntl.fcntl(fd, fcntl.F_SETFD, flags) |
|
293 |
|
|
294 |
|
|
276 | 295 |
def RetryOnSignal(fn, *args, **kwargs): |
277 | 296 |
"""Calls a function again if it failed due to EINTR. |
278 | 297 |
|
Also available in: Unified diff