| 135 | |
| 136 | |
| 137 | Try<RLimitInfo::RLimit> get(RLimitInfo::RLimit::Type type) |
| 138 | { |
| 139 | Try<int> _type = rlimits::convert(type); |
| 140 | if (_type.isError()) { |
| 141 | return Error(_type.error()); |
| 142 | } |
| 143 | |
| 144 | ::rlimit resourceLimit; |
| 145 | if (getrlimit(_type.get(), &resourceLimit) != 0) { |
| 146 | return ErrnoError(); |
| 147 | } |
| 148 | |
| 149 | RLimitInfo::RLimit limit; |
| 150 | limit.set_type(type); |
| 151 | if (resourceLimit.rlim_cur != RLIM_INFINITY) { |
| 152 | limit.set_soft(resourceLimit.rlim_cur); |
| 153 | } |
| 154 | if (resourceLimit.rlim_max != RLIM_INFINITY) { |
| 155 | limit.set_hard(resourceLimit.rlim_max); |
| 156 | } |
| 157 | |
| 158 | return std::move(limit); |
| 159 | } |
| 160 | |
| 161 | } // namespace rlimits { |
| 162 | } // namespace internal { |