From 647eacf13a053bb6a095db69079324e592668368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Thu, 13 Jun 2019 00:00:00 +0000 Subject: [PATCH] userland/c/infinite_loop.c: allow passing a max loop parameter Useful to quickly obtain a simple variable size content. --- userland/c/infinite_loop.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/userland/c/infinite_loop.c b/userland/c/infinite_loop.c index 9c63eb5..ad4f546 100644 --- a/userland/c/infinite_loop.c +++ b/userland/c/infinite_loop.c @@ -13,12 +13,19 @@ #include int main(int argc, char **argv) { - uintmax_t i, j, period; + uintmax_t i, j, period, max; + int max_given; if (argc > 1) { period = strtoumax(argv[1], NULL, 10); } else { period = 100000000; } + if (argc > 2) { + max = strtoumax(argv[2], NULL, 10); + max_given = 1; + } else { + max_given = 0; + } i = 0; j = 0; while (1) { @@ -27,5 +34,7 @@ int main(int argc, char **argv) { printf("%ju\n", j); j++; } + if (max_given && i == max) + break; } }