Skip to content

util/mesa-db: add O_CLOEXEC for cache files

EBADBEEF requested to merge EBADBEEF/mesa:cache-cloexec into main

Any mesa-using process that spawns a new process (fork+exec) will cause the child to inherit potentially hundreds of open shader cache file descriptors.

I noticed this because it broke a test in another project that tried to exercise RLIMIT_NOFILE and assumed only 3 fds were open by default.

Example from a shell spawned from my wayland compositor:

$ ls -l /proc/$$/fd | sort -n -k9
...
lrwx------ 1 user user 64 Oct  3 12:01 124 -> /home/user/.cache/user/mesa_shader_cache_db/part0/mesa_cache.db
lrwx------ 1 user user 64 Oct  3 12:01 125 -> /home/user/.cache/user/mesa_shader_cache_db/part0/mesa_cache.idx
...

Merge request reports

Loading