Sysctl will randomly decide not to load a config file when "sysctl -p" is specified, depending on what's in memory, because it checks the wrong variable to see if it's null. Furthermore, it will sometimes incorrectly report an invalid line in the file, because it uses feof() to check for EOF when feof() may not be true, even at EOF, if stdio hasn't yet realized that it has read everything. The patch below fixes both of these problem. --- sysctl.c.orig Fri Dec 31 10:09:36 1999 +++ sysctl.c Fri Dec 31 10:11:56 1999 @@ -183,13 +183,12 @@ int n = 0; char *name, *value; - if (!name || ((fp = fopen(filename, "r")) == NULL)) { + if (!filename || ((fp = fopen(filename, "r")) == NULL)) { fprintf(stderr, ERR_PRELOAD_FILE, filename); return 0; } /* endif */ - while (!feof(fp)) { - fgets(oneline, 256, fp); + while (fgets(oneline, 256, fp)) { oneline[256] = 0; n++; t = StripLeadingAndTrailingSpaces(oneline);
Created attachment 116 [details] still broken; here's patch for procps-2.0.6-2
This was fixed in procps-2.0.7