diff options
Diffstat (limited to 'web/attachments/41141-check_procs.c.patch')
| -rw-r--r-- | web/attachments/41141-check_procs.c.patch | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/web/attachments/41141-check_procs.c.patch b/web/attachments/41141-check_procs.c.patch new file mode 100644 index 0000000..c152d1b --- /dev/null +++ b/web/attachments/41141-check_procs.c.patch | |||
| @@ -0,0 +1,70 @@ | |||
| 1 | *** check_procs.c.original Fri Jan 31 10:44:15 2003 | ||
| 2 | --- check_procs.c Fri Jan 31 10:44:27 2003 | ||
| 3 | *************** | ||
| 4 | *** 77,82 **** | ||
| 5 | --- 77,83 ---- | ||
| 6 | char *args = ""; | ||
| 7 | char *fmt = ""; | ||
| 8 | char tmp[MAX_INPUT_BUFFER]; | ||
| 9 | + const char *zombie = "Z"; | ||
| 10 | |||
| 11 | int | ||
| 12 | main (int argc, char **argv) | ||
| 13 | *************** | ||
| 14 | *** 93,98 **** | ||
| 15 | --- 94,100 ---- | ||
| 16 | int found = 0; /* counter for number of lines returned in `ps` output */ | ||
| 17 | int procs = 0; /* counter for number of processes meeting filter criteria */ | ||
| 18 | int pos; /* number of spaces before 'args' in `ps` output */ | ||
| 19 | + int cols; /* number of columns in ps output */ | ||
| 20 | |||
| 21 | int result = STATE_UNKNOWN; | ||
| 22 | |||
| 23 | *************** | ||
| 24 | *** 115,128 **** | ||
| 25 | fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process); | ||
| 26 | |||
| 27 | while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { | ||
| 28 | - if ( | ||
| 29 | #ifdef USE_PS_VARS | ||
| 30 | ! sscanf (input_buffer, PS_FORMAT, PS_VARLIST) >= 4 | ||
| 31 | #else | ||
| 32 | ! sscanf (input_buffer, PS_FORMAT, procstat, &procuid, &procppid, &pos, | ||
| 33 | ! procprog) >= 4 | ||
| 34 | #endif | ||
| 35 | ! ) { | ||
| 36 | found++; | ||
| 37 | resultsum = 0; | ||
| 38 | asprintf (&procargs, "%s", input_buffer + pos); | ||
| 39 | --- 117,134 ---- | ||
| 40 | fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process); | ||
| 41 | |||
| 42 | while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { | ||
| 43 | #ifdef USE_PS_VARS | ||
| 44 | ! cols = sscanf (input_buffer, PS_FORMAT, PS_VARLIST); | ||
| 45 | #else | ||
| 46 | ! cols = sscanf (input_buffer, PS_FORMAT, procstat, &procuid, | ||
| 47 | ! &procppid, &pos, procprog); | ||
| 48 | #endif | ||
| 49 | ! /* Zombie processes do not give a procprog command */ | ||
| 50 | ! if ( cols == 3 && strstr(procstat, zombie) ) { | ||
| 51 | ! strcpy(procprog, ""); | ||
| 52 | ! cols = 4; | ||
| 53 | ! } | ||
| 54 | ! if ( cols >= 4 ) { | ||
| 55 | found++; | ||
| 56 | resultsum = 0; | ||
| 57 | asprintf (&procargs, "%s", input_buffer + pos); | ||
| 58 | *************** | ||
| 59 | *** 147,152 **** | ||
| 60 | --- 153,162 ---- | ||
| 61 | #endif | ||
| 62 | if (options == resultsum) | ||
| 63 | procs++; | ||
| 64 | + } | ||
| 65 | + /* This should not happen */ | ||
| 66 | + else if (verbose) { | ||
| 67 | + printf("Not parseable: %s", input_buffer); | ||
| 68 | } | ||
| 69 | } | ||
| 70 | |||
