c - Valgrind 不显示任何信息(因为 exec 调用?)
问题描述
我正在使用 valgrind 检查学校项目的内存泄漏。问题是 valgrind 只显示前几行通常的演示文稿,但没有给我任何有关泄漏和错误的信息:
==4734== Memcheck, a memory error detector
==4734== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==4734== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==4734== Command: ./pipex test_infile grep\ test wc\ -l test_outfile
==4734==
当我不带任何参数运行程序时,它会正确显示信息:
==4626== Memcheck, a memory error detector
==4626== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==4626== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==4626== Command: ./pipex
==4626==
ERROR
==4626==
==4626== HEAP SUMMARY:
==4626== in use at exit: 0 bytes in 0 blocks
==4626== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==4626==
==4626== All heap blocks were freed -- no leaks are possible
==4626==
==4626== For lists of detected and suppressed errors, rerun with: -s
==4626== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
也许是因为我的程序使用了 forks、pipes 和 exec 调用。该程序(pipex)的目标是做到这一点:
./pipex infile cmd1 cmd2 outfile
必须等同于 bash< infile cmd1 | cmd 2 > outfile
关于为什么会发生这种情况以及如何检查错误和泄漏的任何提示?
解决方案
推荐阅读
- sql - SQL 日期过滤器:当开始日期 = 结束日期时返回结果
- java - 根据 StackedBarChart 中的条件对值进行分类和更改颜色
- docker - 需要帮助了解如何从 docker.io 运行应用程序
- node.js - 将 socket.io(^3.0.0) 与 Strapi Server("3.2.5") CORS 错误集成
- reactjs - setState 在本机反应中不切换值
- google-sheets - 使用 IMPORTRANGE 函数时出现奇怪的错误消息
- python - 如何等待使用 Selenium 和 Python 加载的元素数量
- javascript - 尝试在 React 组件中呈现 Firestore 信息 - 使用 useRef() 不重新呈现和 useState() 引发错误
- python - 如何在hackerrank中退出程序之前输出所有输入
- python - 如何在不暴露我的源代码的情况下将 python 嵌入 c++