timeout icon indicating copy to clipboard operation
timeout copied to clipboard

Output memory as KB, MB, GB. Accept memory arguments as KB, MB, GB.

Open ericjster opened this issue 7 years ago • 1 comments

ericjster avatar May 27 '17 03:05 ericjster

Hi Pavel, thanks for reviewing. I agree that people may rely on the output and it should be unaltered. (And yes the output was too verbose, I should have only output it for debug). Before I submit another change, do you think this a good wording for the usage, and good examples?

These days "KiB" and "KB" mean 1024 and "kB" means 1000. We could update the usage text and allow both in the parse_memory_arg subroutine. I am happy to either leave, or add "KiB" and "kB" to follow wikipedia "Kibibyte" definitions. (My preference is to keep it simple.)

Usage:
	timeout [-t timelimit] [-m memlimit] [-s memlimit-rss] [-x hertz] command [arguments ...]

Memory limits may be specified as KB (1024 bytes, default), MB, or GB, and are
output as KB (1024 bytes).

Examples:
timeout -t 2 -m 321.0MB -s 123.4MB perl -e 'while (1) {push @a, 1}'
timeout -t 2 -m 321.0MB -s 123.4MB perl -e 'while (1) {$a += 1}'

The first example will be killed due to exceeding the 123.4 MB rss (resident
set size) limit, and the second example will be killed due to exceeding the 2
second CPU time limit. The values at the time the process is killed will vary
due to the timeout program only waking up periodically to compare the current
values against the limits.

Thanks

ericjster avatar May 29 '17 05:05 ericjster