diff options
author | Roland McGrath <roland@gnu.org> | 2001-04-15 08:10:44 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2001-04-15 08:10:44 +0000 |
commit | 40fd49dcdf0072e4229473f2350f0b8a1ea04a04 (patch) | |
tree | 8ce3be811dca502ba4421099420ddc1548e42d88 /proc/pgrp.c | |
parent | 984d6149fd9d474bec3f80a71bbcd90582139b19 (diff) |
2000-04-03 Neal H Walfield <neal@cs.uml.edu>
* 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): Likewise.
(S_proc_execdata_notify): Check return of malloc.
(S_proc_register_version): Likewise.
(initialize_version_info): Add asserts.
* 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.
Diffstat (limited to 'proc/pgrp.c')
-rw-r--r-- | proc/pgrp.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/proc/pgrp.c b/proc/pgrp.c index ecd4b6e3..665a3472 100644 --- a/proc/pgrp.c +++ b/proc/pgrp.c @@ -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 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <sys/errno.h> #include <stdlib.h> #include <signal.h> +#include <assert.h> #include "proc.h" #include "process_S.h" @@ -39,6 +40,9 @@ new_pgrp (pid_t pgid, 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 @@ new_session (struct proc *p) 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_pgrp (struct pgrp *pg) 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 @@ boot_setsid (struct proc *p) 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 @@ S_proc_getsid (struct proc *callerp, 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 @@ S_proc_getsessionpids (struct proc *callerp, { *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 @@ S_proc_getsessionpgids (struct proc *callerp, { *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 @@ S_proc_getpgrppids (struct proc *callerp, { *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 @@ S_proc_getpgrppids (struct proc *callerp, 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 @@ S_proc_getsidport (struct proc *p, 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 @@ S_proc_setpgrp (struct proc *callerp, 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 @@ S_proc_getpgrp (struct proc *callerp, 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) { |