General return value checks, documentation fixes etc.
diff -urN hurd-20010307-snapshot/proc/ChangeLog hurd-20010313/proc/ChangeLog
--- hurd-20010307-snapshot/proc/ChangeLog Fri Mar 17 11:36:33 2000
+++ hurd-20010313/proc/ChangeLog Mon Mar 26 20:57:24 2001
@@ -1,3 +1,48 @@
+2001-03-25 Neal H Walfield <[EMAIL PROTECTED]>
+
+ * host.c: Doc fix: ``Implement foo as described in <hurd/proc.defs>''
+ => ``Implement foo as described in <hurd/process.defs>''
+ * info.c: Likewise.
+ * mgt.c: Likewise.
+ * pgrp.c: Likewise.
+ * wait.c: Likewise.
+
+ * host.c (S_proc_setexecdata): Check for memory allocation errors.
+ Use memcpy, not bcopy.
+ (S_proc_getexecdata): Use memcpy, not bcopy.
+ * info.c (S_proc_pid2task): Do not bother searching for the pid
+ if we do not have a valid caller.
+ (S_proc_pid2proc): Likewise.
+ Use memcpy, not bcopy.
+ (S_proc_getprocinfo): Doc fixes. Use MAP_FAILED not -1. Use
+ memcpy, not bcopy.
+ (S_proc_getloginpids): Check return value of malloc. Use realloc
+ correctly.
+ (S_proc_setlogin): Check return value of malloc.
+ * main.c (main): Assert allocate_proc.
+ * mgt.c (make_ids): Check return value of malloc and fail
+ accordingly.
+ (S_proc_reauthenticate): Check return value of make_ids and fail
+ accordingly.
+ (S_proc_child): Call task_find after we know that we were passed
+ a valid child.
+ (S_proc_reassign): Likewise.
+ (S_proc_handle_exceptions): Use memcpy, not bcopy.
+ (allocate_proc): Check return value of ports_create_port and fail
+ accordingly.
+ (create_startup_proc): Add asserts.
+ (complete_proc): Do not assume the length of "<none>".
+ * msg.c (S_proc_getmsgport): Call pid_find_allow_zombie after
+ we know we were passed a valid caller.
+ * pgrp.c: Include assert.h.
+ (new_pgrp): Check return value of malloc and fail accordingly.
+ (new_session): Likewise.
+ (boot_setsid): Assert sess.
+ (S_proc_getsessionpids): Use MAP_FAILED not -1.
+ (S_proc_getsessionppids): Likewise.
+ (S_proc_getpgrppids): Likewise.
+ * wait.c (S_proc_wait): Use memset, not bzero.
+
2000-03-17 Roland McGrath <[EMAIL PROTECTED]>
* main.c (main): Use ports_get_send_right.
diff -urN hurd-20010307-snapshot/proc/host.c hurd-20010313/proc/host.c
--- hurd-20010307-snapshot/proc/host.c Tue Sep 16 21:30:42 1997
+++ hurd-20010313/proc/host.c Mon Mar 26 20:57:52 2001
@@ -1,5 +1,5 @@
/* Proc server host management calls
- Copyright (C) 1992, 1993, 1994, 1996, 1997 Free Software Foundation
+ Copyright (C) 1992,93,94,96,97,2001 Free Software Foundation
This file is part of the GNU Hurd.
@@ -55,7 +55,7 @@
} *execdata_notifys;
-/* Implement proc_getprivports as described in <hurd/proc.defs>. */
+/* Implement proc_getprivports as described in <hurd/process.defs>. */
kern_return_t
S_proc_getprivports (struct proc *p,
mach_port_t *hostpriv,
@@ -73,7 +73,7 @@
}
-/* Implement proc_setexecdata as described in <hurd/proc.defs>. */
+/* Implement proc_setexecdata as described in <hurd/process.defs>. */
kern_return_t
S_proc_setexecdata (struct proc *p,
mach_port_t *ports,
@@ -83,12 +83,26 @@
{
int i;
struct execdata_notify *n;
-
+ mach_port_t *std_port_array_new;
+ int *std_int_array_new;
+
if (!p)
return EOPNOTSUPP;
if (!check_uid (p, 0))
return EPERM;
+
+ /* Allocate memory up front. */
+ std_port_array_new = malloc (sizeof (mach_port_t) * nports);
+ if (! std_port_array_new)
+ return ENOMEM;
+
+ std_int_array_new = malloc (sizeof (int) * nints);
+ if (! std_int_array_new)
+ {
+ free (std_port_array_new);
+ return ENOMEM;
+ }
if (std_port_array)
{
@@ -99,13 +113,13 @@
if (std_int_array)
free (std_int_array);
- std_port_array = malloc (sizeof (mach_port_t) * nports);
+ std_port_array = std_port_array_new;
n_std_ports = nports;
- bcopy (ports, std_port_array, sizeof (mach_port_t) * nports);
+ memcpy (std_port_array, ports, sizeof (mach_port_t) * nports);
- std_int_array = malloc (sizeof (int) * nints);
+ std_int_array = std_int_array_new;
n_std_ints = nints;
- bcopy (ints, std_int_array, sizeof (int) * nints);
+ memcpy (std_int_array, ints, sizeof (int) * nints);
for (n = execdata_notifys; n; n = n->next)
exec_setexecdata (n->notify_port, std_port_array, MACH_MSG_TYPE_COPY_SEND,
@@ -114,7 +128,7 @@
return 0;
}
-/* Implement proc_getexecdata as described in <hurd/proc.defs>. */
+/* Implement proc_getexecdata as described in <hurd/process.defs>. */
kern_return_t
S_proc_getexecdata (struct proc *p,
mach_port_t **ports,
@@ -132,18 +146,18 @@
if (*nports < n_std_ports)
*ports = malloc (n_std_ports * sizeof (mach_port_t));
- bcopy (std_port_array, *ports, n_std_ports * sizeof (mach_port_t));
+ memcpy (*ports, std_port_array, n_std_ports * sizeof (mach_port_t));
*nports = n_std_ports;
if (*nints < n_std_ints)
*ints = malloc (n_std_ints * sizeof (mach_port_t));
- bcopy (std_int_array, *ints, n_std_ints * sizeof (int));
+ memcpy (*ints, std_int_array, n_std_ints * sizeof (int));
*nints = n_std_ints;
return 0;
}
-/* Implement proc_execdata_notify as described in <hurd/proc.defs>. */
+/* Implement proc_execdata_notify as described in <hurd/process.defs>. */
kern_return_t
S_proc_execdata_notify (struct proc *p,
mach_port_t notify)
diff -urN hurd-20010307-snapshot/proc/info.c hurd-20010313/proc/info.c
--- hurd-20010307-snapshot/proc/info.c Mon Jan 24 08:14:02 2000
+++ hurd-20010313/proc/info.c Mon Mar 26 20:58:00 2001
@@ -1,5 +1,5 @@
/* Process information queries
- Copyright (C) 1992,93,94,95,96,99,2000 Free Software Foundation, Inc.
+ Copyright (C) 1992,93,94,95,96,99,2000,01 Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -33,17 +33,18 @@
#include "proc.h"
#include "process_S.h"
-/* Implement S_proc_pid2task as described in <hurd/proc.defs>. */
+/* Implement S_proc_pid2task as described in <hurd/process.defs>. */
kern_return_t
S_proc_pid2task (struct proc *callerp,
pid_t pid,
task_t *t)
{
- struct proc *p = pid_find_allow_zombie (pid);
-
+ struct proc *p;
+
if (!callerp)
return EOPNOTSUPP;
+ p = pid_find_allow_zombie (pid);
if (!p)
return ESRCH;
@@ -62,7 +63,7 @@
return 0;
}
-/* Implement proc_task2pid as described in <hurd/proc.defs>. */
+/* Implement proc_task2pid as described in <hurd/process.defs>. */
kern_return_t
S_proc_task2pid (struct proc *callerp,
task_t t,
@@ -80,7 +81,7 @@
return 0;
}
-/* Implement proc_task2proc as described in <hurd/proc.defs>. */
+/* Implement proc_task2proc as described in <hurd/process.defs>. */
kern_return_t
S_proc_task2proc (struct proc *callerp,
task_t t,
@@ -98,7 +99,7 @@
return 0;
}
-/* Implement proc_proc2task as described in <hurd/proc.defs>. */
+/* Implement proc_proc2task as described in <hurd/process.defs>. */
kern_return_t
S_proc_proc2task (struct proc *p,
task_t *t)
@@ -109,17 +110,18 @@
return 0;
}
-/* Implement proc_pid2proc as described in <hurd/proc.defs>. */
+/* Implement proc_pid2proc as described in <hurd/process.defs>. */
kern_return_t
S_proc_pid2proc (struct proc *callerp,
pid_t pid,
mach_port_t *outproc)
{
- struct proc *p = pid_find_allow_zombie (pid);
+ struct proc *p;
if (!callerp)
return EOPNOTSUPP;
+ p = pid_find_allow_zombie (pid);
if (!p)
return ESRCH;
@@ -225,7 +227,7 @@
if (*vec == NULL)
err = ENOMEM;
else
- bcopy ((char *)(data + (addr - readaddr)), *vec,
+ memcpy (*vec, (char *)(data + (addr - readaddr)),
(char *)t - (char *)(data + (addr - readaddr)));
break;
}
@@ -313,7 +315,7 @@
}
-/* Implement proc_getprocargs as described in <hurd/proc.defs>. */
+/* Implement proc_getprocargs as described in <hurd/process.defs>. */
kern_return_t
S_proc_getprocargs (struct proc *callerp,
pid_t pid,
@@ -330,7 +332,7 @@
return get_string_array (p->p_task, p->p_argv, (vm_address_t *) buf, buflen);
}
-/* Implement proc_getprocenv as described in <hurd/proc.defs>. */
+/* Implement proc_getprocenv as described in <hurd/process.defs>. */
kern_return_t
S_proc_getprocenv (struct proc *callerp,
pid_t pid,
@@ -351,7 +353,7 @@
#define PI_FETCH_THREAD_DETAILS \
(PI_FETCH_THREAD_SCHED | PI_FETCH_THREAD_BASIC | PI_FETCH_THREAD_WAITS)
-/* Implement proc_getprocinfo as described in <hurd/proc.defs>. */
+/* Implement proc_getprocinfo as described in <hurd/process.defs>. */
kern_return_t
S_proc_getprocinfo (struct proc *callerp,
pid_t pid,
@@ -489,15 +491,15 @@
continue;
}
if (err)
- /* Something screwy, give up o nthis bit of info. */
+ /* Something screwy, give up on this bit of info. */
{
*flags &= ~PI_FETCH_THREAD_SCHED;
err = 0;
}
}
- /* Note that there are thread wait entries only for threads not marked
- dead. */
+ /* Note that there are thread wait entries only for those threads
+ not marked dead. */
if (*flags & PI_FETCH_THREAD_WAITS)
{
@@ -526,14 +528,14 @@
new_waits = mmap (0, new_len, PROT_READ|PROT_WRITE,
MAP_ANON, 0, 0);
- err = (new_waits == (char *) -1) ? errno : 0;
+ err = (new_waits == MAP_FAILED) ? errno : 0;
if (err)
/* Just don't return any more waits information. */
*flags &= ~PI_FETCH_THREAD_WAITS;
else
{
if (waits_used > 0)
- bcopy (*waits, new_waits, waits_used);
+ memcpy (new_waits, *waits, waits_used);
if (*waits_len > 0 && waits_alloced)
munmap (*waits, *waits_len);
*waits = new_waits;
@@ -545,7 +547,7 @@
if (waits_used + desc_len + 1 <= *waits_len)
/* Append DESC to WAITS. */
{
- bcopy (desc, *waits + waits_used, desc_len);
+ memcpy (*waits + waits_used, desc, desc_len);
waits_used += desc_len;
(*waits)[waits_used++] = '\0';
}
@@ -622,6 +624,9 @@
/* Simple breadth first search of the children of L. */
parraysize = 50;
parray = malloc (sizeof (struct proc *) * parraysize);
+ if (! parray)
+ return ENOMEM;
+
parray[0] = l;
for (tail = parray, new = &parray[1]; tail != new; tail++)
{
@@ -634,6 +639,12 @@
struct proc **newparray;
newparray = realloc (parray, ((parraysize *= 2)
* sizeof (struct proc *)));
+ if (! newparray)
+ {
+ free (parray);
+ return ENOMEM;
+ }
+
tail = newparray + (tail - parray);
new = newparray + (new - parray);
parray = newparray;
@@ -652,10 +663,10 @@
return 0;
}
-/* Implement proc_setlogin as described in <hurd/proc.defs>. */
+/* Implement proc_setlogin as described in <hurd/process.defs>. */
kern_return_t
S_proc_setlogin (struct proc *p,
- char *login)
+ char *login)
{
struct login *l;
@@ -666,6 +677,9 @@
return EPERM;
l = malloc (sizeof (struct login) + strlen (login) + 1);
+ if (! l)
+ return ENOMEM;
+
l->l_refcnt = 1;
strcpy (l->l_name, login);
if (!--p->p_login->l_refcnt)
@@ -674,7 +688,7 @@
return 0;
}
-/* Implement proc_getlogin as described in <hurd/proc.defs>. */
+/* Implement proc_getlogin as described in <hurd/process.defs>. */
kern_return_t
S_proc_getlogin (struct proc *p,
char *login)
@@ -685,7 +699,7 @@
return 0;
}
-/* Implement proc_get_tty as described in <hurd/proc.defs>. */
+/* Implement proc_get_tty as described in <hurd/process.defs>. */
kern_return_t
S_proc_get_tty (struct proc *p, pid_t pid,
mach_port_t *tty, mach_msg_type_name_t *tty_type)
diff -urN hurd-20010307-snapshot/proc/main.c hurd-20010313/proc/main.c
--- hurd-20010307-snapshot/proc/main.c Fri Mar 17 11:31:34 2000
+++ hurd-20010313/proc/main.c Mon Mar 26 20:58:05 2001
@@ -1,5 +1,5 @@
/* Initialization of the proc server
- Copyright (C) 1993,94,95,96,97,99,2000 Free Software Foundation, Inc.
+ Copyright (C) 1993,94,95,96,97,99,2000,01 Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -85,6 +85,8 @@
/* Create our own proc object (we are PID 0). */
self_proc = allocate_proc (mach_task_self ());
+ assert (self_proc);
+
complete_proc (self_proc, 0);
startup_port = ports_get_send_right (startup_proc);
diff -urN hurd-20010307-snapshot/proc/mgt.c hurd-20010313/proc/mgt.c
--- hurd-20010307-snapshot/proc/mgt.c Tue Mar 14 01:49:42 2000
+++ hurd-20010313/proc/mgt.c Mon Mar 26 20:58:10 2001
@@ -1,5 +1,5 @@
/* Process management
- Copyright (C) 1992,93,94,95,96,99,2000 Free Software Foundation, Inc.
+ Copyright (C) 1992,93,94,95,96,99,2000,01 Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -47,15 +47,30 @@
struct ids *i;
i = malloc (sizeof (struct ids));
- i->i_nuids = nuids;
- i->i_ngids = ngids;
+ if (! i)
+ return NULL;
+
i->i_uids = malloc (sizeof (uid_t) * nuids);
+ if (! i->i_uids)
+ goto error_with_i;
+
i->i_gids = malloc (sizeof (uid_t) * ngids);
+ if (! i->i_gids)
+ goto error_with_uids;
+
+ i->i_nuids = nuids;
+ i->i_ngids = ngids;
i->i_refcnt = 1;
memcpy (i->i_uids, uids, sizeof (uid_t) * nuids);
memcpy (i->i_gids, gids, sizeof (uid_t) * ngids);
return i;
+
+error_with_uids:
+ free (i->i_uids);
+error_with_i:
+ free (i);
+ return NULL;
}
/* Free an id structure. */
@@ -79,7 +94,7 @@
}
-/* Implement proc_reathenticate as described in <hurd/proc.defs>. */
+/* Implement proc_reathenticate as described in <hurd/process.defs>. */
kern_return_t
S_proc_reauthenticate (struct proc *p, mach_port_t rendport)
{
@@ -87,6 +102,7 @@
uid_t gubuf[50], aubuf[50], ggbuf[50], agbuf[50];
uid_t *gen_uids, *aux_uids, *gen_gids, *aux_gids;
u_int ngen_uids, naux_uids, ngen_gids, naux_gids;
+ struct ids *new_ids;
if (!p)
return EOPNOTSUPP;
@@ -109,11 +125,16 @@
&aux_gids, &naux_gids);
if (err)
return err;
+
+ new_ids = make_ids (gen_uids, ngen_uids, gen_gids, ngen_gids);
+ if (! new_ids)
+ return ENOMEM;
+
mach_port_deallocate (mach_task_self (), rendport);
if (!--p->p_id->i_refcnt)
free_ids (p->p_id);
- p->p_id = make_ids (gen_uids, ngen_uids, gen_gids, ngen_gids);
+ p->p_id = new_ids;
if (gen_uids != gubuf)
munmap (gen_uids, ngen_uids * sizeof (uid_t));
@@ -127,16 +148,18 @@
return 0;
}
-/* Implement proc_child as described in <hurd/proc.defs>. */
+/* Implement proc_child as described in <hurd/process.defs>. */
kern_return_t
S_proc_child (struct proc *parentp,
task_t childt)
{
- struct proc *childp = task_find (childt);
+ struct proc *childp;
if (!parentp)
return EOPNOTSUPP;
+ childp = task_find (childt);
+
if (!childp)
return ESRCH;
@@ -149,6 +172,7 @@
Leave p_task and p_pid alone; all the rest comes from the
new parent. */
+ /* XXX Race waiting to happen. */
if (!--childp->p_login->l_refcnt)
free (childp->p_login);
childp->p_login = parentp->p_login;
@@ -157,6 +181,7 @@
childp->p_owner = parentp->p_owner;
childp->p_noowner = parentp->p_noowner;
+ /* XXX Race waiting to happen. */
if (!--childp->p_id->i_refcnt)
free_ids (childp->p_id);
childp->p_id = parentp->p_id;
@@ -194,16 +219,18 @@
return 0;
}
-/* Implement proc_reassign as described in <hurd/proc.defs>. */
+/* Implement proc_reassign as described in <hurd/process.defs>. */
kern_return_t
S_proc_reassign (struct proc *p,
task_t newt)
{
- struct proc *stubp = task_find (newt);
+ struct proc *stubp;
if (!p)
return EOPNOTSUPP;
+ stubp = task_find (newt);
+
if (!stubp)
return ESRCH;
@@ -218,7 +245,7 @@
mach_port_destroy (mach_task_self (), p->p_task);
p->p_task = stubp->p_task;
- /* For security, we need use the request port from STUBP */
+ /* For security, we need to use the request port from STUBP */
ports_transfer_right (p, stubp);
/* Enqueued messages might refer to the old task port, so
@@ -245,7 +272,7 @@
return 0;
}
-/* Implement proc_setowner as described in <hurd/proc.defs>. */
+/* Implement proc_setowner as described in <hurd/process.defs>. */
kern_return_t
S_proc_setowner (struct proc *p,
uid_t owner,
@@ -268,7 +295,7 @@
return 0;
}
-/* Implement proc_getpids as described in <hurd/proc.defs>. */
+/* Implement proc_getpids as described in <hurd/process.defs>. */
kern_return_t
S_proc_getpids (struct proc *p,
pid_t *pid,
@@ -283,7 +310,7 @@
return 0;
}
-/* Implement proc_set_arg_locations as described in <hurd/proc.defs>. */
+/* Implement proc_set_arg_locations as described in <hurd/process.defs>. */
kern_return_t
S_proc_set_arg_locations (struct proc *p,
vm_address_t argv,
@@ -296,7 +323,7 @@
return 0;
}
-/* Implement proc_get_arg_locations as described in <hurd/proc.defs>. */
+/* Implement proc_get_arg_locations as described in <hurd/process.defs>. */
kern_return_t
S_proc_get_arg_locations (struct proc *p,
vm_address_t *argv,
@@ -307,7 +334,7 @@
return 0;
}
-/* Implement proc_dostop as described in <hurd/proc.defs>. */
+/* Implement proc_dostop as described in <hurd/process.defs>. */
kern_return_t
S_proc_dostop (struct proc *p,
thread_t contthread)
@@ -328,7 +355,7 @@
for (i = 0; i < nthreads; i++)
{
if (threads[i] != contthread)
- err = thread_suspend (threads[i]);
+ /* err = */ thread_suspend (threads[i]); /* XXX Should we use err? */
mach_port_deallocate (mach_task_self (), threads[i]);
}
if (threads != threadbuf)
@@ -359,7 +386,7 @@
mach_msg_type_number_t statecnt)
{
struct exc *e;
- error_t err;
+ error_t err;
/* No need to check P here; we don't use it. */
@@ -372,7 +399,7 @@
e->forwardport = forwardport;
e->flavor = flavor;
e->statecnt = statecnt;
- bcopy (new_state, e->thread_state, statecnt * sizeof (natural_t));
+ memcpy (e->thread_state, new_state, statecnt * sizeof (natural_t));
ports_port_deref (e);
return 0;
}
@@ -434,7 +461,7 @@
Declare that signal thread hopeless and the task crashed. */
/* Translate the exception code into a signal number
- and mark the process has dying that way. */
+ and mark the process as having died that way. */
hsd.exc = exception;
hsd.exc_code = code;
hsd.exc_subcode = subcode;
@@ -443,8 +470,8 @@
p->p_status = W_EXITCODE (0, signo);
p->p_sigcode = hsd.code;
- /* Nuke the task; we will get a notification message and report it
- died with SIGNO. */
+ /* Nuke the task; we will get a notification message and report that
+ it died with SIGNO. */
task_terminate (task);
ports_port_deref (e);
@@ -478,7 +505,7 @@
}
-/* Implement proc_getallpids as described in <hurd/proc.defs>. */
+/* Implement proc_getallpids as described in <hurd/process.defs>. */
kern_return_t
S_proc_getallpids (struct proc *p,
pid_t **pids,
@@ -520,13 +547,19 @@
struct proc *
allocate_proc (task_t task)
{
+ error_t err;
struct proc *p;
/* Pid 0 is us; pid 1 is init. We handle those here specially;
all other processes inherit from init here (though proc_child
will move them to their actual parent usually). */
- ports_create_port (proc_class, proc_bucket, sizeof (struct proc), &p);
+ err = ports_create_port (proc_class, proc_bucket, sizeof (struct proc), &p);
+ if (err)
+ {
+ errno = err;
+ return NULL;
+ }
p->p_task = task;
p->p_msgport = MACH_PORT_NULL;
@@ -560,6 +593,7 @@
struct proc *p;
p = allocate_proc (MACH_PORT_NULL);
+ assert (p);
p->p_pid = 1;
@@ -573,9 +607,11 @@
p->p_noowner = 0;
p->p_id = make_ids (&zero, 1, &zero, 1);
+ assert (p->p_id);
p->p_loginleader = 1;
p->p_login = malloc (sizeof (struct login) + 5);
+ assert (p->p_login);
p->p_login->l_refcnt = 1;
strcpy (p->p_login->l_name, "root");
@@ -615,9 +651,11 @@
if (!nulllogin)
{
- nulllogin = malloc (sizeof (struct login) + 7);
+#define NULLLOGIN_NAME "<none>"
+ nulllogin = malloc (sizeof (struct login) + sizeof (NULLLOGIN_NAME) + 1);
+ assert (nulllogin);
nulllogin->l_refcnt = 1;
- strcpy (nulllogin->l_name, "<none>");
+ strcpy (nulllogin->l_name, NULLLOGIN_NAME);
}
p->p_pid = pid;
@@ -655,7 +693,12 @@
static struct proc *
new_proc (task_t task)
{
- struct proc *p = allocate_proc (task);
+ struct proc *p;
+
+ p = allocate_proc (task);
+ if (! p)
+ return NULL;
+
complete_proc (p, genpid ());
return p;
}
@@ -825,6 +868,7 @@
int wrapped = 0;
+ /* XXX: Great race here wrt nextpid. */
while (!pidfree (nextpid))
{
++nextpid;
diff -urN hurd-20010307-snapshot/proc/msg.c hurd-20010313/proc/msg.c
--- hurd-20010307-snapshot/proc/msg.c Tue May 4 19:05:27 1999
+++ hurd-20010313/proc/msg.c Mon Mar 26 20:51:10 2001
@@ -1,5 +1,5 @@
/* Message port manipulations
- Copyright (C) 1994, 1995, 1996, 1999 Free Software Foundation
+ Copyright (C) 1994, 1995, 1996, 1999, 2001 Free Software Foundation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -116,10 +116,12 @@
mach_port_t *msgport)
{
int cancel;
- struct proc *p = pid_find_allow_zombie (pid);
+ struct proc *p;
if (!callerp)
return EOPNOTSUPP;
+
+ p = pid_find_allow_zombie (pid);
restart:
while (p && p->p_deadmsg && !p->p_dead)
diff -urN hurd-20010307-snapshot/proc/pgrp.c hurd-20010313/proc/pgrp.c
--- hurd-20010307-snapshot/proc/pgrp.c Sun Jul 11 07:32:01 1999
+++ hurd-20010313/proc/pgrp.c Mon Mar 26 20:52:40 2001
@@ -1,5 +1,5 @@
/* Session and process group manipulation
- Copyright (C) 1992, 1993, 1994, 1995, 1996, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1992,93,94,95,96,99,2001 Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -25,6 +25,7 @@
#include <sys/errno.h>
#include <stdlib.h>
#include <signal.h>
+#include <assert.h>
#include "proc.h"
#include "process_S.h"
@@ -39,6 +40,9 @@
struct pgrp *pg;
pg = malloc (sizeof (struct pgrp));
+ if (! pg)
+ return NULL;
+
pg->pg_plist = 0;
pg->pg_pgid = pgid;
pg->pg_orphcnt = 0;
@@ -61,6 +65,9 @@
struct session *sess;
sess = malloc (sizeof (struct session));
+ if (! sess)
+ return NULL;
+
sess->s_sid = p->p_pid;
sess->s_pgrps = 0;
sess->s_sessionid = MACH_PORT_NULL;
@@ -94,7 +101,7 @@
free (pg);
}
-/* Implement proc_setsid as described in <hurd/proc.defs>. */
+/* Implement proc_setsid as described in <hurd/process.defs>. */
kern_return_t
S_proc_setsid (struct proc *p)
{
@@ -123,11 +130,12 @@
sess = new_session (p);
p->p_pgrp = new_pgrp (p->p_pid, sess);
+ assert (p->p_pgrp);
join_pgrp (p);
return;
}
-/* Implement proc_getsid as described in <hurd/proc.defs>. */
+/* Implement proc_getsid as described in <hurd/process.defs>. */
kern_return_t
S_proc_getsid (struct proc *callerp,
pid_t pid,
@@ -143,7 +151,7 @@
return 0;
}
-/* Implement proc_getsessionpids as described in <hurd/proc.defs>. */
+/* Implement proc_getsessionpids as described in <hurd/process.defs>. */
kern_return_t
S_proc_getsessionpids (struct proc *callerp,
pid_t sid,
@@ -176,6 +184,9 @@
{
*pids = mmap (0, count * sizeof (pid_t), PROT_READ|PROT_WRITE,
MAP_ANON, 0, 0);
+ if (*pids == MAP_FAILED)
+ return errno;
+
pp = *pids;
for (pg = s->s_pgrps; pg; pg = pg->pg_next)
for (p = pg->pg_plist; p; p = p->p_gnext)
@@ -216,6 +227,9 @@
{
*pgids = mmap (0, count * sizeof (pid_t), PROT_READ|PROT_WRITE,
MAP_ANON, 0, 0);
+ if (*pgids == MAP_FAILED)
+ return errno;
+
pp = *pgids;
for (pg = s->s_pgrps; pg; pg = pg->pg_next)
*pp++ = pg->pg_pgid;
@@ -259,6 +273,9 @@
{
*pids = mmap (0, count * sizeof (pid_t), PROT_READ|PROT_WRITE,
MAP_ANON, 0, 0);
+ if (*pids == MAP_FAILED)
+ return errno;
+
pp = *pids;
for (p = pg->pg_plist; p; p = p->p_gnext)
*pp++ = p->p_pid;
@@ -268,7 +285,7 @@
return 0;
}
-/* Implement proc_getsidport as described in <hurd/proc.defs>. */
+/* Implement proc_getsidport as described in <hurd/process.defs>. */
kern_return_t
S_proc_getsidport (struct proc *p,
mach_port_t *sessport, mach_msg_type_name_t *sessport_type)
@@ -291,7 +308,7 @@
return err;
}
-/* Implement proc_setpgrp as described in <hurd/proc.defs>. */
+/* Implement proc_setpgrp as described in <hurd/process.defs>. */
kern_return_t
S_proc_setpgrp (struct proc *callerp,
pid_t pid,
@@ -334,7 +351,7 @@
return 0;
}
-/* Implement proc_getpgrp as described in <hurd/proc.defs>. */
+/* Implement proc_getpgrp as described in <hurd/process.defs>. */
kern_return_t
S_proc_getpgrp (struct proc *callerp,
pid_t pid,
@@ -353,7 +370,7 @@
return 0;
}
-/* Implement proc_mark_exec as described in <hurd/proc.defs>. */
+/* Implement proc_mark_exec as described in <hurd/process.defs>. */
kern_return_t
S_proc_mark_exec (struct proc *p)
{
diff -urN hurd-20010307-snapshot/proc/wait.c hurd-20010313/proc/wait.c
--- hurd-20010307-snapshot/proc/wait.c Tue Jul 16 17:34:26 1996
+++ hurd-20010313/proc/wait.c Mon Mar 26 20:58:30 2001
@@ -1,5 +1,5 @@
/* Implementation of wait
- Copyright (C) 1994, 1995, 1996 Free Software Foundation
+ Copyright (C) 1994, 1995, 1996, 2001 Free Software Foundation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -113,7 +113,7 @@
*sigcode = child->p_sigcode;
if (child->p_dead)
complete_exit (child);
- bzero (ru, sizeof (struct rusage));
+ memset (ru, 0, sizeof (struct rusage));
*pid_status = pid;
return 0;
}
@@ -136,7 +136,7 @@
*pid_status = child->p_pid;
if (child->p_dead)
complete_exit (child);
- bzero (ru, sizeof (struct rusage));
+ memset (ru, 0, sizeof (struct rusage));
return 0;
}
}
@@ -157,7 +157,7 @@
goto start_over;
}
-/* Implement proc_mark_stop as described in <hurd/proc.defs>. */
+/* Implement proc_mark_stop as described in <hurd/process.defs>. */
kern_return_t
S_proc_mark_stop (struct proc *p,
int signo,
@@ -183,7 +183,7 @@
return 0;
}
-/* Implement proc_mark_exit as described in <hurd/proc.defs>. */
+/* Implement proc_mark_exit as described in <hurd/process.defs>. */
kern_return_t
S_proc_mark_exit (struct proc *p,
int status,
@@ -201,7 +201,7 @@
return 0;
}
-/* Implement proc_mark_cont as described in <hurd/proc.defs>. */
+/* Implement proc_mark_cont as described in <hurd/process.defs>. */
kern_return_t
S_proc_mark_cont (struct proc *p)
{
@@ -211,7 +211,7 @@
return 0;
}
-/* Implement proc_mark_traced as described in <hurd/proc.defs>. */
+/* Implement proc_mark_traced as described in <hurd/process.defs>. */
kern_return_t
S_proc_mark_traced (struct proc *p)
{
@@ -221,7 +221,7 @@
return 0;
}
-/* Implement proc_mark_nostopchild as described in <hurd/proc.defs>. */
+/* Implement proc_mark_nostopchild as described in <hurd/process.defs>. */
kern_return_t
S_proc_mod_stopchild (struct proc *p,
int value)
PGP signature