saved up some lines

master
Alessandro Mauri 5 years ago
parent c40b33fb97
commit 31ea134aa3
  1. 19
      bmon.c

@ -123,7 +123,7 @@ int main (int argc, char *argv[])
dead = 1;
}
FILE * ofile_ptr = NULL;
FILE * ofile_ptr = stdout;
if (fflag) {
if (!(ofile_ptr = fopen(ofile_path, "w"))) {
char *tmp = malloc(1024);
@ -145,19 +145,12 @@ int main (int argc, char *argv[])
if (!fgets(buf, 64, fp_list[i]))
dead = 1;
buf[strcspn(buf, "\r\n")] = 0;
if (fflag)
fprintf(ofile_ptr, "%s\t", buf);
else
printf("%s\t", buf);
fprintf(ofile_ptr, "%s\t", buf);
}
if (fflag) {
fprintf(ofile_ptr, "%ld\n", uflag ? time(NULL) : elapsed_time);
if (fflush(ofile_ptr)) {
perror("error writing to file");
dead = 1;
}
} else {
printf("%ld\n", uflag ? time(NULL) : elapsed_time);
fprintf(ofile_ptr, "%ld\n", uflag ? time(NULL) : elapsed_time);
if (fflush(ofile_ptr)) {
perror("error writing to file");
dead = 1;
}
elapsed_time += wait_time;
}

Loading…
Cancel
Save