From 5d4d5abf56790185e06add059e8b7ff824e6f9bf Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Sun, 5 Nov 2006 17:46:33 +0000 Subject: [PATCH] Reset the limits unconditionally. Treat RLIMIT_NOFILE specially, since the kernel does. Fix dietlibc'isms, and handle sys_old_getrlimit's values. git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2371 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- src/exec-ulimit.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/src/exec-ulimit.c b/src/exec-ulimit.c index 7219a9e..37f0b44 100644 --- a/src/exec-ulimit.c +++ b/src/exec-ulimit.c @@ -34,6 +34,13 @@ #define ENSC_WRAPPERS_RESOURCE 1 #include +/* dietlibc specifies this as (~0UL>>1), which is what's returned from + * sys_old_getrlimit, called on some arches for getrlimit. + * Reset it here so the kernel will have the correct values when we set it. */ +#undef RLIM_INFINITY +#define RLIM_INFINITY (~0UL) +#define OLD_RLIM_INFINITY (~0UL>>1) + #define DECLARE_LIMIT(RES,FNAME) { #FNAME, RLIMIT_##RES } int wrapper_exit_code = 255; @@ -159,6 +166,7 @@ int main(int argc, char *argv[]) { size_t i; int cur_fd = Eopen(".", O_RDONLY, 0); + bool in_dir = false; if (argc==2) { if (strcmp(argv[1], "--help")==0) showHelp(1,argv[0],0); @@ -171,19 +179,29 @@ int main(int argc, char *argv[]) } if (chdir(argv[1])!=-1) { - for (i=0; i