 +
 +  // Spawn the process, connecting to stdin, stdout, stderr, and exit.
 +#if !_WIN32
-+#if GTK
++#if (GTK && !__APPLE__)
 +  GSpawnFlags flags = G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH;
 +  if (g_spawn_async_with_pipes(cwd, argv, envp, flags, NULL, NULL, &p->pid,
 +                               &p->fstdin, &p->fstdout, &p->fstderr, &error)) {

+      lua_pushvalue(L, -2), lua_pushboolean(L, 1), lua_settable(L, -3);
+      lua_pop(L, 1); // spawn_procs
+      lua_pushnil(L); // no error
+    } else if (pid == 0) {
+      // Child process: redirect stdin, stdout, and stderr, chdir, and exec.
+      close(pstdin[1]), close(pstdout[0]), close(pstderr[0]);

 #endif			/* } */
 
 
--- a/src/loslib.c	2017-04-19 13:29:57.000000000 -0400
+++ b/src/loslib.c	2018-10-16 17:27:04.962929037 -0400
@@ -4,6 +4,15 @@
 ** See Copyright Notice in lua.h
 */
