Skip to contentSkip to conversation

tools/power turbostat: fix parameter passing for forked command

RFC PATCH New Chen Yu 1 participant 1 message Jul 24, 2015 Turbostat utility

lore
Share & tools
lore

Chen Yu

author
#0 lore raw

RFC PATCH v2 1/1 tools/power turbostat: fix parameter passing for forked command

turbostat supports forked command when sampling cpu state. However, the forked command is not allowed to be executed with options, otherwise turbostat might regard these options as invalid turbostat options. For example:

./turbostat stress -c 4 -t 10
./turbostat: unrecognized option '-t'

This patch solves this problem by pre-pending a '+' to getopt_long's optstring to prevent it from permuting the arguments.

---
 tools/power/x86/turbostat/turbostat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/power/x86/turbostat/turbostat.c +1 -1
index 323b65e..c71cce3 100644
@@ -3042,7 +3042,7 @@ void cmdline(int argc, char **argv)
 
 	progname = argv[0];
 
-	while ((opt = getopt_long_only(argc, argv, "C:c:Ddhi:JM:m:PpST:v",
+	while ((opt = getopt_long_only(argc, argv, "+C:c:Ddhi:JM:m:PpST:v",
 				long_options, &option_index)) != -1) {
 		switch (opt) {
 		case 'C':
Signature · 1 line
1.9.1