posix - posix_spawn 返回代码 14“错误地址”是什么意思?
问题描述
我正在从我的应用程序中生成一个子进程:
QString strFullPath(strModulesPath
+ strModule.toString());
QByteArray baFullPath(strFullPath.toLatin1())
,baSeconds((QString::number(lngSeconds))
.toLatin1());
char** ppEnviron
,* pszFullPath = baFullPath.data()
,* pszSeconds = baSeconds.data()
,* paryszArgs[] = {pszFullPath
,pszSeconds
,nullptr};
posix_spawn_file_actions_t* pfileActionsp;
posix_spawnattr_t* pAttr;
pid_t pid = 0;
pfileActionsp = pAttr = nullptr;
int intRC = posix_spawn(&pid
,pszFullPath
,pfileActionsp
,pAttr
,paryszArgs
,ppEnviron);
要启动的应用程序在 baFullPath 中指定并包含:
~/XMLMPAM/config/modules/mdFileIO
调用 posix_spawn 后返回的 pid 有效,intRC 返回 2。
但是我看不到“活动监视器”中列出的进程,列出了父进程但没有列出子进程。
它在哪里以及如何查看控制台的输出,因为它没有出现在与父进程相同的控制台中。
[编辑] 似乎“posix_spawn”不支持使用路径前缀“~”生成,所以我尝试了完整路径:
/Users/Simon/XMLMPAM/config/modules
我在调试器中查看,现在返回 14,根据错误列表,它是“错误地址”。
[编辑 2] 正如 David Schwartz 所指出的,它不起作用,因为我没有初始化“ppEnviron”。
解决方案
“David Schwartz”在对该问题的评论中指出了该问题的解决方案。
生成操作失败,因为指向环境的指针未初始化为 NULL。
推荐阅读
- c# - 返回 View("viewname", model) 时视图不呈现
- git - Git 推送错误 RPC 失败 curl 52 GnuTLS recv 错误 (-110)
- android - 我无法导入 PhotoView。我该怎么办?
- inheritance - 领域驱动设计 - 继承指南
- android - 选项卡布局或底部导航视图的所有片段的通用搜索视图?
- python - 在不同的结束目录创建文件夹
- python - 将文本拆分为相似的块,但仅在“/>”之后
- angular - 路由器插座内未知的角度组件
- python - 为什么处理许多 CSV 文件的代码在运行时会变慢?
- scroll - 如何在 Vue 3 Composition Api 中滚动时向导航栏添加和删除类