dup2() didn't close the evicted file descriptor (ie. call its close hook) - it just

removed it.
Added comment why there is an explicit dup2() at all.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14312 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-10-06 08:55:19 +00:00
parent 1670b8f596
commit e90c3fec10
+10 -1
View File
@@ -208,6 +208,13 @@ dup_fd(int fd, bool kernel)
}
/** POSIX says this should be the same as:
* close(newfd);
* fcntl(oldfd, F_DUPFD, newfd);
*
* We do dup2() directly to be thread-safe.
*/
static int
dup2_fd(int oldfd, int newfd, bool kernel)
{
@@ -250,8 +257,10 @@ dup2_fd(int oldfd, int newfd, bool kernel)
mutex_unlock(&context->io_mutex);
// Say bye bye to the evicted fd
if (evicted)
if (evicted) {
close_fd(evicted);
put_fd(evicted);
}
return newfd;
}