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:
@@ -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
|
static int
|
||||||
dup2_fd(int oldfd, int newfd, bool kernel)
|
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);
|
mutex_unlock(&context->io_mutex);
|
||||||
|
|
||||||
// Say bye bye to the evicted fd
|
// Say bye bye to the evicted fd
|
||||||
if (evicted)
|
if (evicted) {
|
||||||
|
close_fd(evicted);
|
||||||
put_fd(evicted);
|
put_fd(evicted);
|
||||||
|
}
|
||||||
|
|
||||||
return newfd;
|
return newfd;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user