From a0bae15f2f7e7589b6deea0a0215225c8f6ae0fb Mon Sep 17 00:00:00 2001
From: Petr Baudis <pasky@ucw.cz>
Date: Wed, 7 Mar 2012 17:05:52 +0100
Subject: [PATCH] compctl --limitmem: Value in MiB instead of B

---
 README.client | 4 ++--
 compctl.c     | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/README.client b/README.client
index b5840ad..14af839 100644
--- a/README.client
+++ b/README.client
@@ -20,7 +20,7 @@ Arguments for running computations:
 
 Arguments for controlling computations:
     --usage           show resource usage of all running computations
-    --limitmem MAXMEM change the maximum memory consumed by all computations
+    --limitmem MAXMEM set the maximum memory consumed by all computations [MiB]
     --list            list all running computations
     --stop PGRP       stop a given computation (number as listed in --list)
     --stopall         stop all running computations
@@ -43,5 +43,5 @@ Examples
     compctl --run ./satsolver data.sat | tee results.txt
     compctl --screen autotest-screen 5
 
-    compctl --limitmem 4G
+    compctl --limitmem 4096
     compctl --stop 27134
diff --git a/compctl.c b/compctl.c
index 9151ea5..5571257 100644
--- a/compctl.c
+++ b/compctl.c
@@ -151,7 +151,8 @@ stop_all(void)
 void
 limit_mem(size_t limit)
 {
-	char cmd[256]; snprintf(cmd, sizeof(cmd), "limitmem %zu", limit);
+	char cmd[256];
+	snprintf(cmd, sizeof(cmd), "limitmem %zu", limit * 1048576);
 	char *line = daemon_chat(cmd);
 	if (line[0] != '1') {
 		/* TODO: Error message postprocessing. */
-- 
GitLab