From ac964c54628af8534b811466e68583ef6e685bd2 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 3 Jul 2012 11:40:16 +0200 Subject: Use fdopen() instead of fopen() --- src/indexamajig.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/indexamajig.c') diff --git a/src/indexamajig.c b/src/indexamajig.c index 1981908e..e9ee0f7a 100644 --- a/src/indexamajig.c +++ b/src/indexamajig.c @@ -424,12 +424,12 @@ static void process_image(const struct index_args *iargs, exit(1); } - fh = fopen(outfilename, "a"); + fh = fdopen(fd, "a"); if ( fh == NULL ) { ERROR("Couldn't open stream '%s'.\n", outfilename); } write_chunk(fh, &image, hdfile, iargs->stream_flags); - fclose(fh); + fflush(fh); /* Unlock stream for other processes */ fl.l_type = F_UNLCK; /* set to unlock same region */ @@ -437,7 +437,8 @@ static void process_image(const struct index_args *iargs, ERROR("fcntl"); exit(1); } - close(fd); + + fclose(fh); /* close(fd) happens as well because fd was not dup'd */ /* Only free cell if found */ cell_free(image.indexed_cell); -- cgit v1.2.3