13
0

Fix vfork wrapper for macOS

This commit is contained in:
Robin Gareus 2023-03-25 07:46:47 +01:00
parent 4b5333a721
commit 168c439ee8
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -45,7 +45,17 @@ static int close_allv (const int except_fds[]) {
return -1;
}
for (int fd = 0; fd < (int) rl.rlim_max; fd++) {
int max_fd;
if (rl.rlim_cur >= 4194304) {
/* Impose a sane limit, in case the value is
* RLIM_INFINITY 2^63 -1
*/
max_fd = 4194304;
} else {
max_fd = (int)rl.rlim_cur;
}
for (int fd = 0; fd < max_fd; fd++) {
if (fd <= 3) {
continue;
}
@ -82,8 +92,6 @@ int main(int argc, char *argv[]) {
pout[0] = atoi(argv[5]);
pout[1] = atoi(argv[6]);
int good_fds[3] = { pok[1], pout[1], -1 };
int stderr_mode = atoi(argv[7]);
int nicelevel = atoi(argv[8]);
@ -137,6 +145,7 @@ int main(int argc, char *argv[]) {
signal(SIGPIPE, SIG_DFL);
#endif
int good_fds[2] = { pok[1], -1 };
if (0 == close_allv (good_fds)) {
/* all systems go */
execve(argv[9], &argv[9], envp);