I created new function get_cmd_record() - looks like a fscanf() wrapper for first switch in *get_record().
When something go wrong - eg. open fd, read from fd, etc, get_cmd_record() returns zero as a failure.
I skipped second switch block, for detailed information (write to output name of cmd):
#v+
@@ -418,10 +447,16 @@
get_void(f);
break;
case C_PID:
- fscanf(f, "%d\n", &(p->pid));
+ if(fscanf(f, "%d\n", &(p->pid)) < 0){
+ fprintf(stderr, "Failed to read PID: %s\n", strerror(errno));
+ return NULL;
+ }
break;
case C_EXS:
- fscanf(f, "%u\n", &(p->exstat));
+ if(fscanf(f, "%u\n", &(p->exstat)) < 0){
+ fprintf(stderr, "Failed to read EXS: %s\n", strerror(errno));
+ return NULL;
+ }
break;
case C_LEV:
get_string(p->rlevel, sizeof(p->rlevel), f);
#v-
I skipped setting oops_error, because it's never tested.