Skip to content

Commit de3a939

Browse files
Fall back to get_maxrss when ps doesn't exist
1 parent 98fb99d commit de3a939

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

harness/harness-common.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,13 @@ def get_rss
7575
# Collect our own peak mem usage as soon as reasonable after finishing the last iteration.
7676
# This method is only accurate to kilobytes, but is nicely portable and doesn't require
7777
# any extra gems/dependencies.
78-
mem = `ps -o rss= -p #{Process.pid}`
79-
1024 * Integer(mem)
78+
begin
79+
mem = `ps -o rss= -p #{Process.pid}`
80+
1024 * Integer(mem)
81+
rescue ArgumentError, Errno::ENOENT
82+
# ps failed (e.g. Nix procps on macOS). Fall back to peak RSS via getrusage.
83+
get_maxrss || 0
84+
end
8085
end
8186
end
8287

0 commit comments

Comments
 (0)