return 0;
}
+static int exhaust_memory(int argc, char* argv[]) {
+ const size_t block = 1048576; // 1 MiB
+ size_t bytes = 0;
+
+ while (1) {
+ char* p = malloc(block);
+ if (!p)
+ break;
+
+ bytes += block;
+ }
+
+ printf("Successfully allocated %f MiB\n", (double)bytes / 1048576);
+
+ return 0;
+}
+
static int exit_with_code(int argc, char* argv[]) {
if (argc < 1) {
fprintf(stderr, "exit-with-code requires an argument\n");
else if (strcmp(command, "echo-environ") == 0)
callback = echo_environ;
+ // Exhaust memory
+ else if (strcmp(command, "exhaust-memory") == 0)
+ callback = exhaust_memory;
+
// Exit with code
else if (strcmp(command, "exit-with-code") == 0)
callback = exit_with_code;