patch-1.3.96 linux/drivers/char/pty.c

Next file: linux/drivers/char/riscom8.c
Previous file: linux/drivers/char/misc.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.95/linux/drivers/char/pty.c linux/drivers/char/pty.c
@@ -216,8 +216,9 @@
 	 */
 	if (tty->driver.subtype == PTY_TYPE_MASTER)
 		return 0;
-	add_wait_queue(&pty->open_wait, &wait);
 	retval = 0;
+#if PTY_SLAVE_WAITS_ON_OPEN
+	add_wait_queue(&pty->open_wait, &wait);
 	while (1) {
 		if (current->signal & ~current->blocked) {
 			retval = -ERESTARTSYS;
@@ -226,6 +227,7 @@
 		/*
 		 * Block until the master is open...
 		 */
+		current->state = TASK_INTERRUPTIBLE;
 		if (tty->link->count &&
 		    !test_bit(TTY_OTHER_CLOSED, &tty->flags))
 			break;
@@ -233,6 +235,10 @@
 	}
 	current->state = TASK_RUNNING;
 	remove_wait_queue(&pty->open_wait, &wait);
+#else
+	if (!tty->link->count || test_bit(TTY_OTHER_CLOSED, &tty->flags))
+		retval = -EPERM;
+#endif
 	return retval;
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this