def _set_cloexec(fd):
try:
flags = _fcntl.fcntl(fd, _fcntl.F_GETFD, 0)
except IOError:
pass
else:
# flags read successfully, modify
flags |= _fcntl.FD_CLOEXEC
_fcntl.fcntl(fd, _fcntl.F_SETFD, flags)
path = os.path.join(tramline_upload_path(req), file_id)
try:
fd = os.open(path, tempfile._bin_openflags)
tempfile._set_cloexec(fd)
return fd, path, file_id
except OSError, e:
if e.errno == errno.EEXIST: