logoalt Hacker News

Someoneyesterday at 6:38 PM2 repliesview on HN

MacOS has posix_spawn. See https://developer.apple.com/library/archive/documentation/Sy... (yes, that’s an iOS man page. MacOS has the call, too, but I couldn’t find the man page online and it looks identical to me)

I don’t know how they implemented it, though. Under the hood, it could do the equivalent of a fork/exec pair.


Replies

dcrazyyesterday at 9:23 PM

XNU is open source; here’s a link into the middle of the implementation, after it’s copied all the necessary attributes of the parent into the new process structure: https://github.com/apple-oss-distributions/xnu/blob/f6217f89...

plorkyeranyesterday at 7:08 PM

XNU's posix_spawn implementation is not fork/exec-based. It does roughly what the API suggests it would do.