如果没有足够的文件描述符,可以重命名失败吗?

时间:2021-05-23 10:47:39

I noticed that during a fd leak, while the upper limit of file descriptors was reached a rename call failed. Unfortunately I don't have an error code.

我注意到在fd泄漏期间,当文件描述符的上限达到时,重命名调用失败。不幸的是,我没有错误代码。

Is it possible that the lack of file descriptors is related to the failing of the rename?

文件描述符的缺乏是否与重命名的失败有关?

As far as I can see in the implementation of rename() a link() system call is used. Does it need fd's?

就我所见,在rename()的实现中使用了一个link()系统调用。它需要fd的吗?

The implementation of rename used is from \glibc-2.17\sysdeps\posix\

使用的重命名的实现来自\glibc-2.17\sysdeps\posix\

2 个解决方案

#1


2  

I compiled this program:

我编译这个程序:

#include <stdio.h>

int main()
{
    rename("a", "a1");
}

and ran strace on the executable. Once the initialisation code is complete, all that happens is:

并在可执行文件上运行strace。一旦初始化代码完成,所发生的一切就是:

rename("a", "a1")                       = 0
exit_group(0)                           = ?

i.e. there are no system calls to open new file descriptors.

也就是说,没有系统调用来打开新的文件描述符。

#2


1  

The failure modes of rename are clearly listed on the man page:

人员页面中明确列出了重命名的失败模式:

http://www.manpagez.com/man/2/rename/

http://www.manpagez.com/man/2/rename/

It does not mention too many open files being a problem.

它没有提到太多的打开文件是一个问题。

#1


2  

I compiled this program:

我编译这个程序:

#include <stdio.h>

int main()
{
    rename("a", "a1");
}

and ran strace on the executable. Once the initialisation code is complete, all that happens is:

并在可执行文件上运行strace。一旦初始化代码完成,所发生的一切就是:

rename("a", "a1")                       = 0
exit_group(0)                           = ?

i.e. there are no system calls to open new file descriptors.

也就是说,没有系统调用来打开新的文件描述符。

#2


1  

The failure modes of rename are clearly listed on the man page:

人员页面中明确列出了重命名的失败模式:

http://www.manpagez.com/man/2/rename/

http://www.manpagez.com/man/2/rename/

It does not mention too many open files being a problem.

它没有提到太多的打开文件是一个问题。