summaryrefslogtreecommitdiff
path: root/proc/host.c
diff options
context:
space:
mode:
authorMarcus Brinkmann <marcus@gnu.org>2001-07-13 21:27:43 +0000
committerMarcus Brinkmann <marcus@gnu.org>2001-07-13 21:27:43 +0000
commit3b882621b5de27c1c3ee619ea303eb6448459e8f (patch)
tree57ca067723c0b24981cba27c3623e4a11fb2e57e /proc/host.c
parent3178f3765a76d42e62c0e79e7a21812fbcc15319 (diff)
2001-07-13 Marcus Brinkmann <marcus@gnu.org>
* host.c (S_proc_getexecdata): New variable PORTS_ALLOCATED. Set it if we allocated a new buffer for PORTS. If it is set, and allocation of a new buffer for INTS fails, unmap the buffer for PORTS. * host.c (S_proc_getexecdata): New variable I. Go over all standard ports and increase the send right user reference by one. Set *PORTSPOLY to MACH_MSG_TYPE_MOVE_SEND.
Diffstat (limited to 'proc/host.c')
-rw-r--r--proc/host.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/proc/host.c b/proc/host.c
index 30353a05..b0f7d6e1 100644
--- a/proc/host.c
+++ b/proc/host.c
@@ -138,6 +138,8 @@ S_proc_getexecdata (struct proc *p,
int **ints,
u_int *nints)
{
+ int i;
+ int ports_allocated = 0;
/* No need to check P here; we don't use it. */
if (!std_port_array)
@@ -149,6 +151,7 @@ S_proc_getexecdata (struct proc *p,
PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
if (*ports == MAP_FAILED)
return ENOMEM;
+ ports_allocated = 1;
}
memcpy (*ports, std_port_array, n_std_ports * sizeof (mach_port_t));
*nports = n_std_ports;
@@ -158,11 +161,19 @@ S_proc_getexecdata (struct proc *p,
*ints = mmap (0, round_page (n_std_ints * sizeof (int)),
PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
if (*ints == MAP_FAILED)
- return ENOMEM;
+ {
+ if (ports_allocated)
+ munmap (*ports, round_page (n_std_ports * sizeof (mach_port_t)));
+ return ENOMEM;
+ }
}
memcpy (*ints, std_int_array, n_std_ints * sizeof (int));
*nints = n_std_ints;
+ for (i = 0; i < n_std_ports; i++)
+ mach_port_mod_refs (mach_task_self (), std_port_array[i], MACH_PORT_RIGHT_SEND, 1);
+ *portspoly = MACH_MSG_TYPE_MOVE_SEND;
+
return 0;
}