criu
criu copied to clipboard
Util: close_safe must not clear fd on close() failure
This pull request addresses potential file descriptor leaks in the criu/util.c file by ensuring that file descriptors are properly closed if install_service_fd fails. This improves resource management and prevents leaking system resources.
Resource management improvements:
- In both
set_proc_fdandopen_proc_sfd, added logic to close the duplicated or opened file descriptor ifinstall_service_fdfails, preventing file descriptor leaks. [1] [2]
Looking at the code I see that install_service_fd() already closes the fd if an error happened. Now it is closed twice.
The commit description also does not really match what happens in the code.
This feels like some coding assistant generated changes which look wrong to me.