 +}
 +
 +/** Signal that the child process finished. */
-+static void p_exit(GPid pid, int status, void *data) {
-+  exited((PStream *)data, status);
++static void proc_exited(GPid pid, int status, void *data) {
++  exited(data, status);
 +}
 +#elif !_WIN32
 +/**

+
+#if (GTK && !__APPLE__)
+/** __gc Lua metamethod. */
+static int lp_gc(lua_State *L) {
+  PStream *p = (PStream *)luaL_checkudata(L, 1, "ta_spawn");
+  if (p->pid) {
+    // lua_close() was called, forcing GC. Disconnect listeners since GTK is
+    // still running and may try to invoke callbacks.

+
+/** Signal that channel output is available for reading. */
+static int ch_read(GIOChannel *source, GIOCondition cond, void *data) {
+  PStream *p = data;
+  if (!p->pid || !(cond & G_IO_IN)) return false;
+  char buf[BUFSIZ];
+  size_t len = 0;
+  do {
