Why does Microsoft's _wspawnv return EINVAL?

核能气质少年 提交于 2019-12-24 05:48:52

问题


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.


Edit: 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.

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.


回答1:


Oddly, the documentation also states:

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

How much of it should be trusted?

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



来源:https://stackoverflow.com/questions/923647/why-does-microsofts-wspawnv-return-einval

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!