mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-08 20:00:17 +02:00
When a process is in the process of forking and getting ready for execve, it is common practice to do a `close_range` or close loop to close all file descriptors before the execve. This is a security/sanitization feature to ensure that FDs aren't leaked to the child process. While it is more reliable to have these FDs opened with O_CLOEXEC, people get it wrong all the time so this feature has been put in place. Both python and glibc wrappers for launching applications do this. The problem with this for FEX is that we were using a FILE handle for emitting JIT symbols to the perf file. When the underlying FD is ripped out from under the FILE handle, it throws an assert that we can't recover from. Switching to a raw FD and checking to ensure the FD is still open on writes means that we can safely stop JIT symbol logging when a process is closing FDs under us. Fixes a crash in Steam early startup where a python script is run for checking if packages are installed.