From acd9269478dbc40f1dac64d8f6ddfbb5f562ad09 Mon Sep 17 00:00:00 2001 From: Jonathan Conder Date: Sat, 5 Feb 2011 13:39:37 +1300 Subject: Fix double close of the lock file According to FOPEN(3), using fclose on an fdopen'd file stream also closes the underlying file descriptor. This happened in _alpm_lckmk (util.c), which meant that when alpm_trans_release closed it again, the log file (which reused the original file descriptor) was closed instead. Signed-off-by: Jonathan Conder Signed-off-by: Dan McGee --- lib/libalpm/util.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/libalpm/util.c') diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 458f750a..149a7f80 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -211,7 +211,7 @@ char *_alpm_strtrim(char *str) } /* Create a lock file */ -int _alpm_lckmk(void) +FILE *_alpm_lckmk(void) { int fd; char *dir, *ptr; @@ -234,10 +234,9 @@ int _alpm_lckmk(void) fprintf(f, "%ld\n", (long)getpid()); fflush(f); fsync(fd); - fclose(f); - return(fd); + return(f); } - return(-1); + return(NULL); } /* Remove a lock file */ -- cgit v1.2.3-24-g4f1b