aboutsummaryrefslogtreecommitdiffhomepage
path: root/builtin_ulimit.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2005-11-26 00:16:57 +1000
committerGravatar axel <axel@liljencrantz.se>2005-11-26 00:16:57 +1000
commitdfa251a1ab6936fecd704c65b5c515ca96ce6d20 (patch)
tree50391b75ee2953aa8be8e26b681e7b3f5546cd0c /builtin_ulimit.c
parent82cb97d3e3ad6bf51dbd0decdb731ab947a13529 (diff)
Remove ifdefs from function code
darcs-hash:20051125141657-ac50b-4dabc1dea3c90accafdcab78f683412858d77541.gz
Diffstat (limited to 'builtin_ulimit.c')
-rw-r--r--builtin_ulimit.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/builtin_ulimit.c b/builtin_ulimit.c
index dcd113e1..b9635c9b 100644
--- a/builtin_ulimit.c
+++ b/builtin_ulimit.c
@@ -35,6 +35,10 @@ struct resource_t
Switch used on commandline to specify resource
*/
wchar_t switch_char;
+ /**
+ The implicit multiplier used when setting getting values
+ */
+ int multiplier;
}
;
@@ -44,55 +48,55 @@ struct resource_t
const static struct resource_t resource_arr[] =
{
{
- RLIMIT_CORE, L"Maximum size of core files created", L'c'
+ RLIMIT_CORE, L"Maximum size of core files created", L'c', 1024
}
,
{
- RLIMIT_DATA, L"Maximum size of a process’s data segment", L'd'
+ RLIMIT_DATA, L"Maximum size of a process’s data segment", L'd', 1024
}
,
{
- RLIMIT_FSIZE, L"Maximum size of files created by the shell", L'f'
+ RLIMIT_FSIZE, L"Maximum size of files created by the shell", L'f', 1024
}
,
#if HAVE_RLIMIT_MEMLOCK
{
- RLIMIT_MEMLOCK, L"Maximum size that may be locked into memory", L'l'
+ RLIMIT_MEMLOCK, L"Maximum size that may be locked into memory", L'l', 1024
}
,
#endif
#if HAVE_RLIMIT_RSS
{
- RLIMIT_RSS, L"Maximum resident set size", L'm'
+ RLIMIT_RSS, L"Maximum resident set size", L'm', 1024
}
,
#endif
{
- RLIMIT_NOFILE, L"Maximum number of open file descriptors", L'n'
+ RLIMIT_NOFILE, L"Maximum number of open file descriptors", L'n', 1
}
,
{
- RLIMIT_STACK, L"Maximum stack size", L's'
+ RLIMIT_STACK, L"Maximum stack size", L's', 1024
}
,
{
- RLIMIT_CPU, L"Maximum amount of cpu time in seconds", L't'
+ RLIMIT_CPU, L"Maximum amount of cpu time in seconds", L't', 1
}
,
#if HAVE_RLIMIT_NPROC
{
- RLIMIT_NPROC, L"Maximum number of processes available to a single user", L'u'
+ RLIMIT_NPROC, L"Maximum number of processes available to a single user", L'u', 1
}
,
#endif
#if HAVE_RLIMIT_AS
{
- RLIMIT_AS, L"Maximum amount of virtual memory available to the shell", L'v'
+ RLIMIT_AS, L"Maximum amount of virtual memory available to the shell", L'v', 1024
}
,
#endif
{
- 0, 0
+ 0, 0, 0, 0
}
}
;
@@ -102,16 +106,16 @@ const static struct resource_t resource_arr[] =
*/
static int get_multiplier( int what )
{
-
- if( ( what == RLIMIT_NOFILE ) ||
-#if HAVE_RLIMIT_NPROC
- ( what == RLIMIT_NPROC ) ||
-#endif
- ( what == RLIMIT_CPU ) )
+ int i;
+
+ for( i=0; resource_arr[i].desc; i++ )
{
- return 1;
+ if( resource_arr[i].resource == what )
+ {
+ return resource_arr[i].multiplier;
+ }
}
- return 1024;
+ return -1;
}
/**