Flush output streams. Do not fclose stdout/stdin.

This commit is contained in:
Michael Ossmann
2021-01-27 12:12:45 -07:00
parent a6fa7876cb
commit 2ca991e1df
2 changed files with 9 additions and 3 deletions

View File

@ -757,6 +757,7 @@ int main(int argc, char** argv) {
fprintf(stderr, "hackrf_exit() done\n"); fprintf(stderr, "hackrf_exit() done\n");
} }
fflush(outfile);
if ( ( outfile != NULL ) && ( outfile != stdout ) ) { if ( ( outfile != NULL ) && ( outfile != stdout ) ) {
fclose(outfile); fclose(outfile);
outfile = NULL; outfile = NULL;

View File

@ -1141,9 +1141,14 @@ int main(int argc, char** argv) {
rewind(file); rewind(file);
fwrite(&wave_file_hdr, 1, sizeof(t_wav_file_hdr), file); fwrite(&wave_file_hdr, 1, sizeof(t_wav_file_hdr), file);
} }
fclose(file); if (file != stdin) {
file = NULL; fflush(file);
fprintf(stderr, "fclose(file) done\n"); }
if ((file != stdout) && (file != stdin)) {
fclose(file);
file = NULL;
fprintf(stderr, "fclose() done\n");
}
} }
fprintf(stderr, "exit\n"); fprintf(stderr, "exit\n");
return exit_code; return exit_code;