为什么微软的 _wspawnv 返回 EINVAL? [英] Why does Microsoft's _wspawnv return EINVAL?

查看:29
本文介绍了为什么微软的 _wspawnv 返回 EINVAL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在调用 Microsoft 的 _wspawnv 函数,它不断返回 -1,并将 errno 设置为 22;errno.h 将其定义为 EINVAL.根据 Microsoft 的 _wspawnv 文档,仅当 mode 参数无效时才应返回此代码.我尝试在第一个参数中使用 _P_WAIT 和 _P_NOWAIT 调用它,并且都返回相同的错误.<小时>令人惊讶的是,离开一天可以解决多少问题.我很快就意识到第二个参数中的文件名周围有引号.把它们拿出来,问题解决了.

I'm calling Microsoft's _wspawnv function, and it keeps returning -1 with errno set to 22; errno.h defines this as EINVAL. According to Microsoft's documentation for _wspawnv, this code should only be returned if the mode parameter is invalid. I've tried calling it with _P_WAIT and _P_NOWAIT in the first parameter, and both return the same error.


It's amazing how many problems can be solved by going away for a day. It didn't take me long to realize that the filename in the second parameter had quotes around it. Took them out, problem solved.

故事的寓意 - 不要相信文档会告诉您一切.我没有花很多时间仔细检查文件名,因为文档没有将其列为可能的嫌疑人,即使错误代码暗示 any 参数可能无效.

Moral of the story - don't trust the documentation to tell you everything. I didn't spend a lot of time double-checking the filename because the documentation didn't list it as a possible suspect, even though the error code implied that any parameter might be invalid.

推荐答案

奇怪的是,文档 还指出:

如果允许继续执行,这些函数将 errno 设置为 EINVAL,并返回 -1.不会产生新的进程.

If execution is allowed to continue, these functions set errno to EINVAL, and return -1. No new process is spawned.

应该信任多少?

此外,它不应该返回 EINVAL.它将 errno 设置为 EINVAL.

Also, it isn't supposed to return EINVAL. It sets errno to EINVAL.

这篇关于为什么微软的 _wspawnv 返回 EINVAL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆