RLIM_INFINITY support for RLIMIT_NOFILE (patch)
Good day all, I recently found that the linux kernel does not support setting a process' RLIMIT_NOFILE limits to the #define RLIM_INFINITY. My patch will add such support by setting the limit to the maximum supported by the kernel when a call to set a limit to RLIM_INFINITY is made.
I understand that the semantics do not match exactly but all kernels are limited by real hard limits and/or available memory, I think that it is therefore acceptable to have a call to set a limit to RLIM_INFINITY actually set the limit to the maximum extent supported by the kernel.
Patch by: Andrew Wansink & Chris Leishman Against: Linux 2.4.6 Date: (Friday the 13th) 13th July 2001 File: kernel/sys.c
sys.c renamed from sys.c.orig +4 -0
@@ -1119,6 +1119,10 @@return -EINVAL ;if (copy_from_user (&new_rlim, rlim,sizeof (*rlim)))return -EFAULT ; +if (new_rlim.rlim_cur ==RLIM_INFINITY ) + new_rlim.rlim_cur =NR_OPEN ; +if (new_rlim.rlim_max ==RLIM_INFINITY ) + new_rlim.rlim_max =NR_OPEN ;if (new_rlim.rlim_cur <0 || new_rlim.rlim_max <0 )return -EINVAL ; old_rlim = current->rlim + resource;