- while (fgets(buffer, 1024, fp_popen) != NULL) {
- /* Following code should be in while loop as llstat
- * will keep on sending output each second and will
- * not exit on itself. It will be killed when we finsh
- * with our command so we must make the output file
- * consistent after writing each 1024 bytes chunk */
-
- /* opening file where llstat will write its output */
- fp_out = fopen(llstat_file, "a");
- if (!fp_out) {
- fprintf(stderr, "Error: Couldn't open llstat"
- "outfile file: %s\n",
- llstat_file);
- exit(1);
- }
- /* fgets reads the popen output and fprintf writes it to
- * output file */
-
- if (fputs(buffer, fp_out) == EOF) {
- fprintf(stderr, "Error: Couldn't write output"
- "of llstat to out file\n");
- exit(1);
- }
-
- /* closing file opened for storing llstat's output */
- if (fclose(fp_out)) {
- fprintf(stderr, "Error: Couldn't close llstat"
- "outfile: %s\n", llstat_file);
- exit(1);
- }
- }
+ while (fgets(buffer, LLSTAT_READ_SIZE, fp_popen) != NULL) {
+ /* Following code should be in while loop as llstat
+ * will keep on sending output each second and will
+ * not exit on itself. It will be killed when we finsh
+ * with our command so we must make the output file
+ * consistent after writing each 1024 bytes chunk */
+
+ /* opening file where llstat will write its output */
+ fp_out = fopen(llstat_file, "a");
+ if (!fp_out) {
+ fprintf(stderr, "Error: Couldn't open llstat"
+ "outfile file: %s\n",
+ llstat_file);
+ exit(1);
+ }
+ /* fgets reads the popen output and fprintf writes it to
+ * output file */
+
+ if (fputs(buffer, fp_out) == EOF) {
+ fprintf(stderr, "Error: Couldn't write output"
+ "of llstat to out file\n");
+ exit(1);
+ }
+
+ /* closing file opened for storing llstat's output */
+ if (fclose(fp_out)) {
+ fprintf(stderr, "Error: Couldn't close llstat"
+ "outfile: %s\n", llstat_file);
+ exit(1);
+ }
+ }