From adb91fd3dbe763566c6e5d088767091ec8205a4d Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Mon, 20 Jan 2025 15:51:02 -0500
Subject: [PATCH] process: Don't use vfork() on Apple platforms.
They want you to use fork(), which is almost-identical in their implementation.
They mark vfork() usage with a big scary deprecation warning.
---
src/process/posix/SDL_posixprocess.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/process/posix/SDL_posixprocess.c b/src/process/posix/SDL_posixprocess.c
index 8dc01603408d8..98b9f75bca8e8 100644
--- a/src/process/posix/SDL_posixprocess.c
+++ b/src/process/posix/SDL_posixprocess.c
@@ -309,10 +309,16 @@ bool SDL_SYS_CreateProcessWithProperties(SDL_Process *process, SDL_PropertiesID
// Spawn the new process
if (process->background) {
int status = -1;
- pid_t pid = vfork();
+ #ifdef SDL_PLATFORM_APPLE // Apple has vfork marked as deprecated and (as of macOS 10.12) is almost identical to calling fork() anyhow.
+ const pid_t pid = fork();
+ const char *forkname = "fork";
+ #else
+ const pid_t pid = vfork();
+ const char *forkname = "vfork";
+ #endif
switch (pid) {
case -1:
- SDL_SetError("vfork() failed: %s", strerror(errno));
+ SDL_SetError("%s() failed: %s", forkname, strerror(errno));
goto posix_spawn_fail_all;
case 0: