mirror of
https://github.com/janet-lang/janet
synced 2025-10-17 08:47:39 +00:00
Add CLOEXECs when getting file descriptors (#374)
This should help address leaking file descriptors in multithreaded programs. There are a few cases where a race can occur though, as some apis (fopen and mktemp).
This commit is contained in:
@@ -606,7 +606,7 @@ static Janet os_cryptorand(int32_t argc, Janet *argv) {
|
||||
In both cases, use this fallback path for now... */
|
||||
int rc;
|
||||
int randfd;
|
||||
RETRY_EINTR(randfd, open("/dev/urandom", O_RDONLY));
|
||||
RETRY_EINTR(randfd, open("/dev/urandom", O_RDONLY | O_CLOEXEC));
|
||||
if (randfd < 0)
|
||||
janet_panic(genericerr);
|
||||
while (n > 0) {
|
||||
|
Reference in New Issue
Block a user