Closed
Description
File descriptor closing in spawn_process_os
in libnative
on Unix platforms misses file descriptors opened before lowered resource limits.
The code is here: https://github.com/mozilla/rust/blob/master/src/libnative/io/process.rs#L581.
I know on BSD one can use closefrom
and on Linux one can use /proc/self/fd
.
The following code demonstrates how a file can be carried in over lowered resource limits.
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <sys/resource.h>
int main() {
struct rlimit const limit = {
.rlim_cur = 0,
.rlim_max = 0
};
if (-1 == setrlimit(RLIMIT_NOFILE, &limit)) {
fprintf(stderr, "error: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
puts("Printing to standard output even though the resource limit is lowered past standard output's number!");
return EXIT_SUCCESS;
}