aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_fork.c
diff options
context:
space:
mode:
authorDon Lewis <truckman@FreeBSD.org>1998-11-09 15:08:04 +0000
committerDon Lewis <truckman@FreeBSD.org>1998-11-09 15:08:04 +0000
commit643a8daaafc69088eaf5e47159c5a91fe4e802eb (patch)
treeef7e370b41f51c4e0d21035acb075a9637221e37 /sys/kern/kern_fork.c
parent87bc830f60ed8f0d6eaebcbf0abbbc8f83b6d611 (diff)
downloadsrc-643a8daaafc69088eaf5e47159c5a91fe4e802eb.tar.gz
src-643a8daaafc69088eaf5e47159c5a91fe4e802eb.zip
If the session leader dies, s_leader is set to NULL and getsid() may
dereference a NULL pointer, causing a panic. Instead of following s_leader to find the session id, store it in the session structure. Jukka found the following info: BTW - I just found what I have been looking for. Std 1003.1 Part 1: SYSTEM API [C LANGUAGE] section 2.2.2.80 states quite explicitly... Session lifetime: The period between when a session is created and the end of lifetime of all the process groups that remain as members of the session. So, this quite clearly tells that while there is any single process in any process group which is a member of the session, the session remains as an independent entity. Reviewed by: peter Submitted by: "Jukka A. Ukkonen" <jau@jau.tmt.tele.fi>
Notes
Notes: svn path=/head/; revision=41038
Diffstat (limited to 'sys/kern/kern_fork.c')
-rw-r--r--sys/kern/kern_fork.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index 26cbe47576d6..a1f6c859fe89 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_fork.c 8.6 (Berkeley) 4/8/94
- * $Id: kern_fork.c,v 1.50 1997/12/12 04:00:58 dyson Exp $
+ * $Id: kern_fork.c,v 1.51 1998/01/22 17:29:46 dyson Exp $
*/
#include "opt_ktrace.h"
@@ -271,7 +271,8 @@ retry:
again:
for (; p2 != 0; p2 = p2->p_list.le_next) {
while (p2->p_pid == nextpid ||
- p2->p_pgrp->pg_id == nextpid) {
+ p2->p_pgrp->pg_id == nextpid ||
+ p2->p_session->s_sid == nextpid) {
nextpid++;
if (nextpid >= pidchecked)
goto retry;
@@ -281,6 +282,9 @@ again:
if (p2->p_pgrp->pg_id > nextpid &&
pidchecked > p2->p_pgrp->pg_id)
pidchecked = p2->p_pgrp->pg_id;
+ if (p2->p_session->s_sid > nextpid &&
+ pidchecked > p2->p_session->s_sid)
+ pidchecked = p2->p_session->s_sid;
}
if (!doingzomb) {
doingzomb = 1;