Apple's window.c changes between upstream screen-4.0.3
and their release of screen, called screen-24.
You can view the screen-24 source at
https://opensource.apple.com/tarballs/screen/

Upstream screen-4.0.3 is released under the GPLv2,
so Apple's changes (this patch) is a derivative work and
also licensed under the GPLv2.

This patch was then rebased against the latest upstream
GNU Screen, which was version 4.6.2 and no longer required
many of Apple's changes. This was done by David Gilman
for MacPorts.
--- window.c	2024-08-28 15:55:03.000000000 -0400
+++ window.c	2024-08-31 09:20:45.386555415 -0400
@@ -37,10 +37,13 @@
 #include <sys/stat.h>
 #include <signal.h>
 #include <stdint.h>
 #include <stdbool.h>
 #include <fcntl.h>
+#ifdef __APPLE__
+#include <unistd.h>
+#endif /* __APPLE__ */
 #include <sys/ioctl.h>
 #include <sys/wait.h>

 #include "fileio.h"
 #include "help.h"
@@ -1182,10 +1185,44 @@
 	if (slave != -1)
 		close(slave);
 	return pid;
 }

+#ifdef __APPLE__
+#ifdef RUN_LOGIN
+/*
+ * All of the logic to maintain utmpx is now built into /usr/bin/login, so
+ * all we need to do is call it, and pass the shell command to it.
+ */
+extern char *LoginName;
+
+static int
+run_login(const char *path, char *const argv[], char *const envp[])
+{
+	const char *shargs[MAXARGS + 1 + 3];
+	const char **fp, **tp;
+
+	if (access(path, X_OK) < 0)
+		return -1;
+	shargs[0] = "login";
+	shargs[1] = (*argv[0] == '-') ? "-pfq" : "-pflq";
+	shargs[2] = LoginName;
+	shargs[3] = path;
+	fp = (const char **)argv + 1;
+	tp = shargs + 4;
+	/* argv has already been check for length */
+	while ((*tp++ = *fp++) != NULL) {}
+	/* shouldn't return unless there was an error */
+	return (execve("/usr/bin/login", (char *const*)shargs, envp));
+}
+
+/* replace the following occurrences of execve() with run_login() */
+#define execve run_login
+
+#endif /* RUN_LOGIN */
+#endif /* __APPLE__ */
+
 #ifndef HAVE_EXECVPE
 void execvpe(char *prog, char **args, char **env)
 {
 	char *path = NULL;
 	char buf[1024];