Well, now I can post my beautifully formatted answer, here it is:
Per
int fd = _open(name,oflags);
Replace
int fd; errno_t errno = _sopen_s(&fd,name,oflags,_SH_DENYNO,0);
The reason I posted these questions and answers is because they contain important non-obvious information that Microsoft did not provide. I agree that _sopen_s is a bad replacement for _open. I investigated this topic only because I corrected the error caused by invalid arguments passed to _sopen_s. _Sopen_s was only in code to get rid of compiler warnings; The original _open call was ok.
source share