Skip to content
Permalink
Browse files

handle missing ulimit on e.g. csh shells. resolves #191

  • Loading branch information...
jooh committed Feb 21, 2019
1 parent 222744c commit 0bf9a9ffc119438f385747f3d52211a478370fa9
Showing with 42 additions and 26 deletions.
  1. +42 −26 extrafunctions/meminfo.m
@@ -48,26 +48,31 @@

% limits

[ status, result ] = system('ulimit -m');

result = deblank(result);

if strcmp(result,'unlimited')
M.ResLimit = Inf;
else
M.ResLimit = str2double(result);
end

[ status, result ] = system('ulimit -v');

result = deblank(result);

if strcmp(result,'unlimited')
M.VirtLimit = Inf;
else
M.VirtLimit = str2double(result);
end

try
[ status, result ] = system('ulimit -m');
result = deblank(result);
if strcmp(result,'unlimited')
M.ResLimit = Inf;
else
M.ResLimit = str2double(result);
end
catch
fprintf('ulimit not available, defaulting to inf\n');
M.ResLimit = Inf;
end

try
[ status, result ] = system('ulimit -v');
result = deblank(result);
if strcmp(result,'unlimited')
M.VirtLimit = Inf;
else
M.VirtLimit = str2double(result);
end
catch
M.VirtLimit = Inf;
end

% process

% assuming ps returns results in KB
@@ -101,13 +106,24 @@

% limits

[junk, out] = aas_shell('ulimit -m',true); out = deblank(out);
if strcmp(out,'unlimited'), dat = Inf;
else dat = str2double(out); end
try
[junk, out] = aas_shell('ulimit -m',true);
out = deblank(out);
if strcmp(out,'unlimited'), dat = Inf;
else dat = str2double(out); end
catch
fprintf('ulimit not available, defaulting to inf\n');
dat = Inf;
end
M.ResLimit = dat;
[junk, out] = aas_shell('ulimit -v',true); out = deblank(out);
if strcmp(out,'unlimited'), dat = Inf;
else dat = str2double(out); end

try
[junk, out] = aas_shell('ulimit -v',true);
out = deblank(out);
if strcmp(out,'unlimited'), dat = Inf;
else dat = str2double(out); end
catch
dat = Inf;
M.VirtLimit = dat;

% process

0 comments on commit 0bf9a9f

Please sign in to comment.
You can’t perform that action at this time.