7 ms·
Of all the quirks with process spawning in posix keeping file descriptors open is the most problematic one I encountered. This bit into my ass while implementin
by oseityphelysiol 2y ago
Of all the quirks with process spawning in posix keeping file descriptors open is the most problematic one I encountered. This bit into my ass while implementing a C library to have proper process spawning and stdio handling in LUA. I really wish file descriptors were non inheritable by default.
- teddyh 2y ago> I really wish file descriptors were non inheritable by default. In Python 3.4, they are (released ten years ago).
- int_19h 2y agoBut in POSIX, they are not, so any module implemented in C is still potentially problematic.
- teddyh 2y agoOnly if that C-implemented module uses raw C to create file descriptors. And if the module has not gotten an update in the past ten years to fix the problem.
- jcalvinowens 2y agoThis can help: https://man7.org/linux/man-pages/man2/close_range.2.html https://man7.org/linux/man-pages/man2/close_range.2.html close_range(3, ~0U, CLOSE_RANGE_UNSHARE); execve(....); ...but it's not very portable yet.
- deleted 2y ago[deleted]
- oseityphelysiol 2y agoI’ve never heard of it before. I work in an embedded environment where kernel version is known beforehand, so portability won’t be an issue. Thanks.