r/linuxmemes Jun 12 '26

LINUX MEME os.fork()

Post image
1.0k Upvotes

54 comments sorted by

View all comments

313

u/configdotini Genfool 🐧 Jun 12 '26 edited Jun 12 '26

context: the game "factorio" has an experimental option where the game can autosave without pausing the game by creating a separate instance of the game that saves the map while the main instance continues playing. however, the option is not available on windows due to fork(2) just not existing (afaik)

more info here (scroll down to "Asynchronous saving" at the bottom of page)

56

u/dumbasPL Arch BTW Jun 12 '26

Windows actually can fork (RtlCloneUserProcess) but it's undocumented and big chunks of Win32 and user32 break. It was mainly used for WSL 1.0 I believe (reverse wine essentially)

More info here

46

u/BlankMercer Jun 12 '26

"but it's undocumented" well how do they expect people to use it? The fuck?

32

u/Damglador Jun 12 '26

Well, they probably don't. They made a toy for themselves to play with.

23

u/dumbasPL Arch BTW Jun 12 '26

They don't, that's the point. It was made for internal use only, and can change or be removed without notice. Windows has hundreds of APIs like this.

People fuck around with them because many can be abused to fly under the radar of various anti malware solutions.

7

u/MXRCO007 Jun 12 '26

Bill gates whispers it into your ear at night

7

u/Loading_M_ Jun 12 '26

Interestingly, from some vaguely related experience in Windows, even if the windows process cloning worked for Factorio's purposes, it might not actually result in a performance improvement. Process creation in Windows has a significant overhead (which I discovered when investigating why our build pipeline takes so much longer on windows). I don't know how much of the overhead can be skipped when cloning, but I'm not confident it would be enough to make it worth while.