00001
00002
00003
00004
00005
00006
00007
00008
00009 static const char rcsid[] __attribute__((used)) = "$Id: ResourceLimit.cpp 1197 2014-10-14 22:26:11Z sella $";
00010
00011 #include "ResourceLimit.h"
00012
00013 #include <sys/resource.h>
00014
00015 using namespace sella::util;
00016
00017 ResourceLimit::ResourceLimit() throw () { }
00018
00019 ResourceLimit::ResourceLimit(const ResourceLimit &other) { }
00020
00021 ResourceLimit::~ResourceLimit() {
00022 clear();
00023 }
00024
00025 ResourceLimit& ResourceLimit::operator=(const ResourceLimit &other) throw () {
00026 if (this != &other) {
00027 }
00028
00029 return *this;
00030 }
00031
00032 void ResourceLimit::setCoredumpSize(unsigned long size, Type type) throw (ResourceLimitException) {
00033 struct rlimit limit;
00034
00035 if (type == Both) {
00036 limit.rlim_cur = limit.rlim_max = size;
00037 } else if (type == Hard) {
00038 limit.rlim_max = size;
00039 } else {
00040 limit.rlim_cur = size;
00041 }
00042
00043 if (setrlimit(RLIMIT_CORE, &limit) != 0) {
00044 THROW2(ResourceLimitException, "Failed to adjust coredump size: ");
00045 }
00046 }
00047
00048 unsigned long ResourceLimit::getCoredumpSize(Type type) throw (ResourceLimitException) {
00049 struct rlimit limit;
00050
00051 if (getrlimit(RLIMIT_CORE, &limit) != 0) {
00052 THROW2(ResourceLimitException, "Failed to access coredump size: ");
00053 }
00054
00055 return limit.rlim_cur;
00056 }
00057
00058 void ResourceLimit::clear(void) throw () {
00059 }
00060
00061 const ResourceLimit::shared ResourceLimit::shared_ptr(void) throw () {
00062 return std::make_shared<ResourceLimit>();
00063 }
00064
00065
00066
00067