我正在使用valgrind来检测内存泄漏。但是,valgrind检测程序中的fd泄漏。如下。
==00:00:00:40.685 31162== FILE DESCRIPTORS: 4 open at exit.
==00:00:00:40.685 31162== Open file descriptor 3: client.valgrind(this is open by valgrind)
==00:00:00:40.685 31162== <inherited from parent>
==00:00:00:40.685 31162==
==00:00:00:40.685 31162== Open file descriptor 2: /dev/pts/19
==00:00:00:40.685 31162== <inherited from parent>
==00:00:00:40.685 31162==
==00:00:00:40.685 31162== Open file descriptor 1: /dev/pts/19
==00:00:00:40.685 31162== <inherited from parent>
==00:00:00:40.685 31162==
==00:00:00:40.685 31162== Open file descriptor 0: /dev/pts/19
==00:00:00:40.685 31162== <inherited from parent>
但是client.valgrind是valgrind的日志文件,0,1,2是标准输出输入和err文件fd。我不敢睁开它们。我感到困惑。
答案 0 :(得分:0)
我不认为这应该被认为是一个问题,valgrind告诉你这些问题是完全正常的。为什么要以不同的方式处理前3个fd?如果您在从close(0); close(1); close(2);
返回之前关闭它们(main
),这些打印输出将会消失,但这显然是不必要的。