Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Use memfd_create + /proc/self/fd/{FD} for temporary DL on Linux. #228

Merged
merged 1 commit into from
Jul 27, 2021

Conversation

heiner
Copy link
Contributor

@heiner heiner commented Jul 26, 2021

If memfd_create is unavailable, try using O_TMPFILE via tempfile.TemporaryFile.

MacOS has no memfd_create or O_TMPFILE. Unfortunately, using /dev/fd/{FD} as an argument to dlopen doesn't work either after unlinking from the file system (see https://gist.github.com/heiner/5179ccaef983b318c1fc451d7efbe95d#file-tmp_memfs_mac-py). So let's copy instead and hope vardir gets properly deleted at some point.

If memfd_create is unavailable, try using O_TMPFILE via
tempfile.TemporaryFile.

MacOS has no memfd_create or O_TMPFILE. Unforunately, using
/dev/fd/{FD} as an argument to dlopen doesn't work either after
unlinking from the file system (see
https://gist.github.com/heiner/5179ccaef983b318c1fc451d7efbe95d#file-tmp_memfs_mac-py).
So let's copy instead and hope vardir gets properly deleted at some
point.
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 26, 2021
@heiner heiner requested a review from tscmoo July 26, 2021 17:38
@heiner
Copy link
Contributor Author

heiner commented Jul 26, 2021

Thanks to @tscmoo for suggesting this!

@heiner heiner merged commit f9e3939 into master Jul 27, 2021
@heiner heiner deleted the heiner/memfd-hack branch July 27, 2021 12:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants