summaryrefslogtreecommitdiff
path: root/ndb
diff options
context:
space:
mode:
authorunknown <tomas@mc05.(none)>2004-05-12 12:52:07 +0200
committerunknown <tomas@mc05.(none)>2004-05-12 12:52:07 +0200
commit15db58a446e3ddbe600328cee5386db1cab505cd (patch)
tree24e332981bc816056092e56e4b6d2ebc126ff952 /ndb
parent2e9dee04e082c7b61b57d4754c72a2ecfd67c75e (diff)
parentde861db3e73b72a01eceed23095c4793f893d6c4 (diff)
downloadmariadb-git-15db58a446e3ddbe600328cee5386db1cab505cd.tar.gz
Merge tulin@bk-internal.mysql.com:/home/bk/mysql-4.1
into mc05.(none):/space/tomas/mysql-4.1-ndb
Diffstat (limited to 'ndb')
-rw-r--r--ndb/src/cw/cpcd/Process.cpp36
1 files changed, 20 insertions, 16 deletions
diff --git a/ndb/src/cw/cpcd/Process.cpp b/ndb/src/cw/cpcd/Process.cpp
index 4c6bf6ce0f6..74426306a88 100644
--- a/ndb/src/cw/cpcd/Process.cpp
+++ b/ndb/src/cw/cpcd/Process.cpp
@@ -25,7 +25,9 @@
#include "CPCD.hpp"
#include <pwd.h>
+#ifdef HAVE_GETRLIMIT
#include <sys/resource.h>
+#endif
void
CPCD::Process::print(FILE * f){
@@ -205,6 +207,7 @@ setup_environment(const char *env) {
static
int
set_ulimit(const BaseString & pair){
+#ifdef HAVE_GETRLIMIT
errno = 0;
do {
Vector<BaseString> list;
@@ -212,42 +215,43 @@ set_ulimit(const BaseString & pair){
if(list.size() != 2){
break;
}
-
- int resource = 0;
+
+ int res;
rlim_t value = RLIM_INFINITY;
if(!(list[1].trim() == "unlimited")){
value = atoi(list[1].c_str());
}
+
+ struct rlimit rlp;
+#define _RLIMIT_FIX(x) { res = getrlimit(x,&rlp); if(!res){ rlp.rlim_cur = value; res = setrlimit(x, &rlp); }}
+
if(list[0].trim() == "c"){
- resource = RLIMIT_CORE;
+ _RLIMIT_FIX(RLIMIT_CORE);
} else if(list[0] == "d"){
- resource = RLIMIT_DATA;
+ _RLIMIT_FIX(RLIMIT_DATA);
} else if(list[0] == "f"){
- resource = RLIMIT_FSIZE;
+ _RLIMIT_FIX(RLIMIT_FSIZE);
} else if(list[0] == "n"){
- resource = RLIMIT_NOFILE;
+ _RLIMIT_FIX(RLIMIT_NOFILE);
} else if(list[0] == "s"){
- resource = RLIMIT_STACK;
+ _RLIMIT_FIX(RLIMIT_STACK);
} else if(list[0] == "t"){
- resource = RLIMIT_CPU;
+ _RLIMIT_FIX(RLIMIT_CPU);
} else {
errno = EINVAL;
break;
}
- struct rlimit rlp;
- if(getrlimit(resource, &rlp) != 0){
+ if(!res)
break;
- }
-
- rlp.rlim_cur = value;
- if(setrlimit(resource, &rlp) != 0){
- break;
- }
+
return 0;
} while(false);
logger.error("Unable to process ulimit: %s(%s)",
pair.c_str(), strerror(errno));
return -1;
+#else
+ return 0; // Maybe it's ok anyway...
+#endif
}
void