I got some questions in a chat room the other day which prompted me to realize I'm using
fork in a way that's completely within specification but uncommon. I decided I had better understand
fork on Windows before going too much farther. And it looks as if I'm screwed.
Most people call
fork as a means to an end. They want to start another process or they want some concurrency. I call
fork as an end in itself; I want precisely what it does, no more and no less. I want a clone of the current process, including the address space, so I can drop privileges and run to completion as a regular (non-root) user.
It turns out Windows doesn't support
fork. At all.
If you're one of those people who call
fork as a means to an end, you have alternatives. If you were just going to call
exec after
fork, then replace both calls with
CreateProcess. If you just wanted some concurrency, then call
CreateThread instead.
But I'm not one of those people. I actually want
fork to fork. So I'm screwed.
The question now is what to do about it. Do I abandon support for Windows? Or do I re-architect into separate processes? I am frankly leaning toward ditching Windows support, since I would never in a million years use it myself, and since fork is super-cheap on Linux, which is key support for being able to claim Counterpart is fast.
Update: It seems silly to kick Windows to the curb just because I'll have to write some different engine code that will be slower. The valuable code is the extensions. At worst, the Windows implementation can be a regular CGI program, and someone who cares enough will come along and figure out how to make it fast. That someone might even be me.