this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Stop leaking fds in pthread_chdir

This was causing EMFILE in applications that frequently use pthread_chdir.

+5 -1
+5 -1
src/kernel/emulation/linux/bsdthread/pthread_chdir.c
··· 10 10 11 11 long sys_pthread_chdir(const char* path) 12 12 { 13 - int rv, newfd; 13 + int rv, newfd, oldfd; 14 14 15 15 newfd = sys_open(path, BSD_O_RDONLY | BSD_O_DIRECTORY | BSD_O_CLOEXEC, 0); 16 16 if (newfd < 0) 17 17 return newfd; 18 + 19 + oldfd = get_perthread_wd(); 20 + if (oldfd != LINUX_AT_FDCWD) 21 + close_internal(oldfd); 18 22 19 23 set_perthread_wd(newfd); 20 24 return 0;