From 9fec909970b00ba7275e0a533f4818b792722a8e Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Mon, 1 Dec 2014 18:36:56 +0100 Subject: [PATCH] Indirectly closedir(3) from exit(3). --- libc/dirent/dnewdir.cpp | 1 + libc/include/DIR.h | 1 + libc/stdlib/exit.cpp | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libc/dirent/dnewdir.cpp b/libc/dirent/dnewdir.cpp index b2f0148b..c7946ce0 100644 --- a/libc/dirent/dnewdir.cpp +++ b/libc/dirent/dnewdir.cpp @@ -39,6 +39,7 @@ extern "C" DIR* dnewdir(void) return NULL; dir->flags = 0; dir->free_func = dfreedir; + dir->closedir_indirect = closedir; dregister(dir); return dir; } diff --git a/libc/include/DIR.h b/libc/include/DIR.h index 065afa85..26c83bb5 100644 --- a/libc/include/DIR.h +++ b/libc/include/DIR.h @@ -59,6 +59,7 @@ struct DIR int (*close_func)(void* user); void (*free_func)(DIR* dir); /* Application writers shouldn't use anything beyond this point. */ + int (*closedir_indirect)(DIR*); DIR* prev; DIR* next; struct dirent* entry; diff --git a/libc/stdlib/exit.cpp b/libc/stdlib/exit.cpp index 161af10f..8ccda665 100644 --- a/libc/stdlib/exit.cpp +++ b/libc/stdlib/exit.cpp @@ -62,7 +62,7 @@ extern "C" void exit(int status) pthread_mutex_lock(&__first_file_lock); while ( __first_dir ) - closedir(__first_dir); + __first_dir->closedir_indirect(__first_dir); while ( __first_file ) fclose(__first_file);