Although returning '1' is probably right, it's up to the application to
decide. The data structure for number of running processes is an 'int',
so '-1' clearly indicates something's wrong when interpreting the data.
Conflicts:
src/processes.c
char buffer[4096] = {};
char id[] = "procs_running "; /* white space terminated */
char *running;
+ char *endptr = NULL;
+ long result = 0L;
ssize_t status;
*/
running = strstr(buffer, id);
if (!running) {
- WARNING("procs_running not found, assuming 1");
- return 1;
+ WARNING("procs_running not found");
+ return -1;
}
running += strlen(id);
- return atoi(running);
+ result = strtol(running, &endptr, 10);
+ if ( (*running != '\0') && ((*endptr == '\0') || (*endptr == '\n')) ) {
+ return (int)result;
+ }
+
+ return -1;
}
static char *ps_get_cmdline(long pid, char *name, char *buf, size_t buf_len) {