patch-2.1.39 linux/drivers/char/tty_io.c

Next file: linux/drivers/scsi/eata.c
Previous file: linux/arch/i386/kernel/irq.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.38/linux/drivers/char/tty_io.c linux/drivers/char/tty_io.c
@@ -838,7 +838,7 @@
 {
 	struct tty_struct *tty, *o_tty;
 	struct termios *tp, *o_tp, *ltp, *o_ltp;
-	struct task_struct **p;
+	struct task_struct *p;
 	int	idx;
 	
 	tty = (struct tty_struct *)filp->private_data;
@@ -972,14 +972,14 @@
 	 * Make sure there aren't any processes that still think this
 	 * tty is their controlling tty.
 	 */
-	for (p = &LAST_TASK ; p > &FIRST_TASK ; --p) {
-		if (*p == 0)
-			continue;
-		if ((*p)->tty == tty)
-			(*p)->tty = NULL;
-		if (o_tty && (*p)->tty == o_tty)
-			(*p)->tty = NULL;
+	read_lock(&tasklist_lock);
+	for_each_task(p) {
+		if (p->tty == tty)
+			p->tty = NULL;
+		if (o_tty && p->tty == o_tty)
+			p->tty = NULL;
 	}
+	read_unlock(&tasklist_lock);
 
 	/*
 	 * Shutdown the current line discipline, and reset it to
@@ -1216,40 +1216,6 @@
 	return 0;
 }
 
-#if 0
-/*
- * XXX does anyone use this anymore?!?
- */
-static int do_get_ps_info(unsigned long arg)
-{
-	struct tstruct {
-		int flag;
-		int present[NR_TASKS];
-		struct task_struct tasks[NR_TASKS];
-	};
-	struct tstruct *ts = (struct tstruct *)arg;
-	struct task_struct **p;
-	char *c, *d;
-	int i, n = 0;
-	
-	i = verify_area(VERIFY_WRITE, (void *)arg, sizeof(struct tstruct));
-	if (i)
-		return i;
-	for (p = &FIRST_TASK ; p <= &LAST_TASK ; p++, n++)
-		if (*p)
-		{
-			c = (char *)(*p);
-			d = (char *)(ts->tasks+n);
-			for (i=0 ; i<sizeof(struct task_struct) ; i++)
-				put_user(*c++, d++);
-			put_user(1, ts->present+n);
-		}
-		else	
-			put_user(0, ts->present+n);
-	return(0);			
-}
-#endif
-
 static int tiocsti(struct tty_struct *tty, char * arg)
 {
 	char ch, mbz = 0;
@@ -1495,7 +1461,7 @@
 #ifdef TTY_SOFT_SAK
 	tty_hangup(tty);
 #else
-	struct task_struct **p;
+	struct task_struct *p;
 	int session;
 	int		i;
 	struct file	*filp;
@@ -1507,23 +1473,23 @@
 		tty->ldisc.flush_buffer(tty);
 	if (tty->driver.flush_buffer)
 		tty->driver.flush_buffer(tty);
- 	for (p = &LAST_TASK ; p > &FIRST_TASK ; --p) {
-		if (!(*p))
-			continue;
-		if (((*p)->tty == tty) ||
-		    ((session > 0) && ((*p)->session == session)))
-			send_sig(SIGKILL, *p, 1);
-		else if ((*p)->files) {
+	read_lock(&tasklist_lock);
+	for_each_task(p) {
+		if ((p->tty == tty) ||
+		    ((session > 0) && (p->session == session)))
+			send_sig(SIGKILL, p, 1);
+		else if (p->files) {
 			for (i=0; i < NR_OPEN; i++) {
-				filp = (*p)->files->fd[i];
+				filp = p->files->fd[i];
 				if (filp && (filp->f_op == &tty_fops) &&
 				    (filp->private_data == tty)) {
-					send_sig(SIGKILL, *p, 1);
+					send_sig(SIGKILL, p, 1);
 					break;
 				}
 			}
 		}
 	}
+	read_unlock(&tasklist_lock);
 #endif
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov