 +        &p->fstderr, &error)) {
 +    p->cstdout = new_channel(p->fstdout, p, p->stdout_cb > 0);
 +    p->cstderr = new_channel(p->fstderr, p, p->stderr_cb > 0);
-+    if (p->exit_cb != LUA_REFNIL)
-+      g_child_watch_add_full(
-+        G_PRIORITY_DEFAULT + 1, p->pid, proc_exited, p, NULL);
++    g_child_watch_add(p->pid, proc_exited, p);
 +    lua_pushnil(L); // no error
 +  } else {
 +    lua_pushnil(L);

+    g_source_remove_by_user_data(p); // disconnect cstdout watch
+    g_source_remove_by_user_data(p); // disconnect cstderr watch
+    g_source_remove_by_user_data(p); // disconnect child watch
+  }
+  return 0;
+}

+    if (lua_pcall(L, 1, 0, 0) != LUA_OK)
+      fprintf(stderr, "Lua: %s\n", lua_tostring(L, -1)), lua_pop(L, 1);
+  }
+#if GTK && !__APPLE__
+  g_source_remove_by_user_data(p); // disconnect cstdout watch
+  g_source_remove_by_user_data(p); // disconnect cstderr watch
+  g_source_remove_by_user_data(p); // disconnect child watch
+  g_spawn_close_pid(p->pid);
+#elif (!GTK || __APPLE__)
+  // Stop tracking and monitoring this proc.
+  lua_getfield(L, LUA_REGISTRYINDEX, "spawn_procs");
