MINOR: config: support process ranges for "bind-process"
Several users have already been caught by "bind-process" which does not
support ranges, so let's support them now.
diff --git a/src/dumpstats.c b/src/dumpstats.c
index 5f59dde..8264506 100644
--- a/src/dumpstats.c
+++ b/src/dumpstats.c
@@ -305,7 +305,8 @@
unsigned int set = 0;
while (*args[cur_arg]) {
- int u;
+ unsigned int low, high;
+
if (strcmp(args[cur_arg], "all") == 0) {
set = 0;
break;
@@ -316,15 +317,33 @@
else if (strcmp(args[cur_arg], "even") == 0) {
set |= 0xAAAAAAAA;
}
- else {
- u = str2uic(args[cur_arg]);
- if (u < 1 || u > 32) {
- memprintf(err,
- "'%s %s' expects 'all', 'odd', 'even', or process numbers from 1 to 32.\n",
- args[0], args[1]);
+ else if (isdigit(*args[cur_arg])) {
+ char *dash = strchr(args[cur_arg], '-');
+
+ low = high = str2uic(args[cur_arg]);
+ if (dash)
+ high = str2uic(dash + 1);
+
+ if (high < low) {
+ unsigned int swap = low;
+ low = high;
+ high = swap;
+ }
+
+ if (low < 1 || high > 32) {
+ memprintf(err, "'%s %s' supports process numbers from 1 to 32.\n",
+ args[0], args[1]);
return -1;
}
- set |= 1 << (u - 1);
+
+ while (low <= high)
+ set |= 1 << (low++ - 1);
+ }
+ else {
+ memprintf(err,
+ "'%s %s' expects 'all', 'odd', 'even', or a list of process ranges with numbers from 1 to 32.\n",
+ args[0], args[1]);
+ return -1;
}
cur_arg++;
}