mirror of
https://github.com/darlinghq/darling.git
synced 2025-02-17 08:09:10 +00:00
Stop leaking fds in pthread_chdir
This was causing EMFILE in applications that frequently use pthread_chdir.
This commit is contained in:
parent
d8702a85de
commit
617d552eb8
@ -10,12 +10,16 @@
|
||||
|
||||
long sys_pthread_chdir(const char* path)
|
||||
{
|
||||
int rv, newfd;
|
||||
int rv, newfd, oldfd;
|
||||
|
||||
newfd = sys_open(path, BSD_O_RDONLY | BSD_O_DIRECTORY | BSD_O_CLOEXEC, 0);
|
||||
if (newfd < 0)
|
||||
return newfd;
|
||||
|
||||
oldfd = get_perthread_wd();
|
||||
if (oldfd != LINUX_AT_FDCWD)
|
||||
close_internal(oldfd);
|
||||
|
||||
set_perthread_wd(newfd);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user