 +} PStream;
 +
 +/** p:status() Lua function. */
-+static int lp_status(lua_State *L) {
-+  PStream *p = (PStream *)luaL_checkudata(L, 1, "ta_spawn");
-+  lua_pushstring(L, p->pid ? "running" : "terminated");
-+  return 1;
++static int proc_status(lua_State *L) {
++  PStream *p = luaL_checkudata(L, 1, "ta_spawn");
++  return (lua_pushstring(L, p->pid ? "running" : "terminated"), 1);
 +}
 +
 +/** Process exit cleanup function. */

+}
+
+/** p:wait() Lua function. */
+static int lp_wait(lua_State *L) {
+  PStream *p = (PStream *)luaL_checkudata(L, 1, "ta_spawn");
+  if (!p->pid) return (lua_pushinteger(L, p->exit_status), 1);
+#if !_WIN32
+  int status;

+ */
+int os_spawn_pushfds(lua_State *L) {
+  int nfds = 1;
+  fd_set *fds = lua_newuserdata(L, sizeof(fd_set));
+  FD_ZERO(fds);
+  lua_getfield(L, LUA_REGISTRYINDEX, "spawn_procs");
+  for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
+    PStream *p = lua_touserdata(L, -2);
+    FD_SET(p->fstdout, fds);
+    FD_SET(p->fstderr, fds);
+    if (p->fstdout >= nfds) nfds = p->fstdout + 1;
+    if (p->fstderr >= nfds) nfds = p->fstderr + 1;
+  }
+  lua_pop(L, 1); // spawn_procs
+  return nfds;
