about summary refs log tree commit diff
path: root/sysdeps/mach/hurd/spawni.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/mach/hurd/spawni.c')
-rw-r--r--sysdeps/mach/hurd/spawni.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/sysdeps/mach/hurd/spawni.c b/sysdeps/mach/hurd/spawni.c
index 4fd0cdd520..c08f2a5b5a 100644
--- a/sysdeps/mach/hurd/spawni.c
+++ b/sysdeps/mach/hurd/spawni.c
@@ -457,7 +457,7 @@ __spawni (pid_t *pid, const char *file,
 	    {								      \
 	      /* We need to expand the dtable for the child.  */	      \
 	      NEW_TABLE (dtable, newfd);				      \
-	      NEW_TABLE (ulink_dtable, newfd);				      \
+	      NEW_ULINK_TABLE (ulink_dtable, newfd);			      \
 	      NEW_TABLE (dtable_cells, newfd);				      \
 	      dtablesize = newfd + 1;					      \
 	    }								      \
@@ -468,6 +468,16 @@ __spawni (pid_t *pid, const char *file,
   memcpy (new_##x, x, dtablesize * sizeof (x[0]));			      \
   memset (&new_##x[dtablesize], 0, (newfd + 1 - dtablesize) * sizeof (x[0])); \
   x = new_##x; } while (0)
+#define NEW_ULINK_TABLE(x, newfd) \
+  do { __typeof (x) new_##x = __alloca ((newfd + 1) * sizeof (x[0]));	      \
+  unsigned i;								      \
+  for (i = 0; i < dtablesize; i++)					      \
+    if (dtable_cells[i] != NULL)					      \
+      _hurd_port_move (dtable_cells[i], &new_##x[i], &x[i]);		      \
+    else								      \
+      memset(&new_##x[i], 0, sizeof(new_##x[i]));			      \
+  memset (&new_##x[dtablesize], 0, (newfd + 1 - dtablesize) * sizeof (x[0])); \
+  x = new_##x; } while (0)
 
 	struct __spawn_action *action = &file_actions->__actions[i];