Fix a bug with processing the options to the program
being measured were consumed as options to task itself.

For example:

task -e PM_RUN_CYC /bin/ls -l

was being interpreted by getopt() as:

task -e PM_RUN_CYC -l /bin/ls

and task didn't understand the -l option.

According to the getopt() man page, a '+' can be inserted at the
front of the options processing string so that option processing
will stop at the first non-option, instead of looking for options
past that point.  Adding this '+' fixed the above problem.
---
 perf_examples/task.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/perf_examples/task.c b/perf_examples/task.c
index 35ba0b8..7cbe502 100644
--- a/perf_examples/task.c
+++ b/perf_examples/task.c
@@ -353,7 +353,7 @@ main(int argc, char **argv)
 
        setlocale(LC_ALL, "");
 
-       while ((c=getopt(argc, argv,"he:ifpPt:")) != -1) {
+       while ((c=getopt(argc, argv,"+he:ifpPt:")) != -1) {
                switch(c) {
                        case 'e':
                                if (options.num_groups < MAX_GROUPS) {
-- 
1.7.0.4


------------------------------------------------------------------------------

_______________________________________________
perfmon2-devel mailing list
perfmon2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perfmon2-devel

Reply via email to