os-posix: Expand setrlimit() syscall compatibility
PATCH 1/1 os-posix: Expand setrlimit() syscall compatibility
Darwin (I'm running version 19.6.0) uses a subtly different version of the setrlimit() syscall as described in the COMPATIBILITY section of the macOS man page. I adjusted the way the rlim_cur member is set to accommodate and which shouldn't affect any non-Darwin systems.
--- os-posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
os-posix.c +1 -1
@@ -270,7 +270,7 @@ void os_setup_limits(void)return ; } - nofile.rlim_cur = nofile.rlim_max; + nofile.rlim_cur =OPEN_MAX < nofile.rlim_max ?OPEN_MAX : nofile.rlim_max;if (setrlimit (RLIMIT_NOFILE , &nofile) <0 ) {warn_report ("unable to set NOFILE limit: %s" ,strerror (errno));
Signature · 1 line
2.24.3 (Apple Git-128)
Quoted 15 lines · Trent Huber
Darwin (I'm running version 19.6.0) uses a subtly different version of the
setrlimit()syscall as described in the COMPATIBILITY section of the macOS man page. I adjusted the way therlim_curmember is set to accommodate and which shouldn't affect any non-Darwin systems.Signed-off-by Trent Huber <[email protected]>--- os-posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)os-posix.c +0
-0
os-posix.c void os_setup_limits(void) · line 273
Quoted 5 lines
os-posix.c +1
-1@@ -270,7 +270,7 @@ void os_setup_limits(void)return ; } - nofile.rlim_cur = nofile.rlim_max; + nofile.rlim_cur =OPEN_MAX < nofile.rlim_max ?OPEN_MAX : nofile.rlim_max;
There's no such constant OPEN_MAX on Linux, so this doesn't compile.
There is a sysconf() parameter _SC_OPEN_MAX, but we should not use that as it is a dynamic value that just reflects what 'rlim_cur' is set to, and would thus turn this into a no-op.
This should just be made conditional to macOS, since its the only problematic platform that we known of.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 30 lines · Daniel P. Berrangé
Quoted 15 lines · Trent Huber
Darwin (I'm running version 19.6.0) uses a subtly different version of the
setrlimit()syscall as described in the COMPATIBILITY section of the macOS man page. I adjusted the way therlim_curmember is set to accommodate and which shouldn't affect any non-Darwin systems.Signed-off-by Trent Huber <[email protected]>---
os-posix.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)os-posix.c +0
-0os-posix.c void os_setup_limits(void) · line 273
Quoted 5 lines
os-posix.c +1
-1@@ -270,7 +270,7 @@ void os_setup_limits(void)return ; } - nofile.rlim_cur = nofile.rlim_max; + nofile.rlim_cur =OPEN_MAX < nofile.rlim_max ?OPEN_MAX : nofile.rlim_max;There's no such constant
OPEN_MAXon Linux, so this doesn't compile.There is a
sysconf()parameter_SC_OPEN_MAX, but we should not use that as it is a dynamic value that just reflects what 'rlim_cur' is set to, and would thus turn this into a no-op.
Quoted 9 lines
This should just be made conditional to macOS, since its the only problematic platform that we known of.
With regards,
DanielSignature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Thanks for looking this over, I'll add some conditionals and send a v2 of the patch.
Kindly,
Trent