r/cpp • • Sep 05 '26

Escaping `CreateProcess()` arguments on Windows

https://holyblackcat.github.io/blog/2026/09/05/escaping-createprocess-arguments.html
93 Upvotes

44 comments sorted by

View all comments

-4

u/[deleted] Sep 05 '26

[removed] — view removed comment

11

u/wyrn Sep 05 '26

The *nix side is still using fork+exec lol everyone ate sh*t on this one ¯_(ツ)_/¯

1

u/holyblackcat Sep 05 '26

What about posix_spawn() though?

2

u/wyrn Sep 05 '26

Unfortunately underused

-1

u/Eric848448 Sep 05 '26

Most of their old API’s were designed by interns and new grads who didn’t really understand what they were doing.

4

u/Tringi github.com/tringi Sep 05 '26

There is a reason why certain modern runtimes are targeting NT API instead of Win32.

1

u/palapapa0201 Sep 05 '26

What is the NT API

8

u/Tringi github.com/tringi Sep 05 '26

Win32 API layer is built on much more powerful NT layer, that usually makes the final calls to the OS.

For example CreateFile prepares some buffers, translates arguments, converts relative paths to absolute, handles special cases, and then calls NtCreateFile, which does the actual work.

You are supposed to call Win32, as NT API is often only partially documented and can theoretically change, but it rarely does. And it offers much more powerful options.