@@ -1960,7 +1960,7 @@ static struct tty_struct *tty_open_current_tty(dev_t device, struct file *filp)
1960
1960
* Locking: tty_mutex protects get_tty_driver
1961
1961
*/
1962
1962
static struct tty_driver * tty_lookup_driver (dev_t device , struct file * filp ,
1963
- int * noctty , int * index )
1963
+ int * index )
1964
1964
{
1965
1965
struct tty_driver * driver ;
1966
1966
@@ -1970,7 +1970,6 @@ static struct tty_driver *tty_lookup_driver(dev_t device, struct file *filp,
1970
1970
extern struct tty_driver * console_driver ;
1971
1971
driver = tty_driver_kref_get (console_driver );
1972
1972
* index = fg_console ;
1973
- * noctty = 1 ;
1974
1973
break ;
1975
1974
}
1976
1975
#endif
@@ -1981,7 +1980,6 @@ static struct tty_driver *tty_lookup_driver(dev_t device, struct file *filp,
1981
1980
if (driver ) {
1982
1981
/* Don't let /dev/console block */
1983
1982
filp -> f_flags |= O_NONBLOCK ;
1984
- * noctty = 1 ;
1985
1983
break ;
1986
1984
}
1987
1985
}
@@ -2036,14 +2034,13 @@ static int tty_open(struct inode *inode, struct file *filp)
2036
2034
if (retval )
2037
2035
return - ENOMEM ;
2038
2036
2039
- noctty = filp -> f_flags & O_NOCTTY ;
2040
2037
index = -1 ;
2041
2038
retval = 0 ;
2042
2039
2043
2040
tty = tty_open_current_tty (device , filp );
2044
2041
if (!tty ) {
2045
2042
mutex_lock (& tty_mutex );
2046
- driver = tty_lookup_driver (device , filp , & noctty , & index );
2043
+ driver = tty_lookup_driver (device , filp , & index );
2047
2044
if (IS_ERR (driver )) {
2048
2045
retval = PTR_ERR (driver );
2049
2046
goto err_unlock ;
@@ -2091,10 +2088,6 @@ static int tty_open(struct inode *inode, struct file *filp)
2091
2088
tty_add_file (tty , filp );
2092
2089
2093
2090
check_tty_count (tty , __func__ );
2094
- if (tty -> driver -> type == TTY_DRIVER_TYPE_PTY &&
2095
- tty -> driver -> subtype == PTY_TYPE_MASTER )
2096
- noctty = 1 ;
2097
-
2098
2091
tty_debug_hangup (tty , "opening (count=%d)\n" , tty -> count );
2099
2092
2100
2093
if (tty -> ops -> open )
@@ -2127,6 +2120,12 @@ static int tty_open(struct inode *inode, struct file *filp)
2127
2120
2128
2121
read_lock (& tasklist_lock );
2129
2122
spin_lock_irq (& current -> sighand -> siglock );
2123
+ noctty = (filp -> f_flags & O_NOCTTY ) ||
2124
+ device == MKDEV (TTY_MAJOR , 0 ) ||
2125
+ device == MKDEV (TTYAUX_MAJOR , 1 ) ||
2126
+ (tty -> driver -> type == TTY_DRIVER_TYPE_PTY &&
2127
+ tty -> driver -> subtype == PTY_TYPE_MASTER );
2128
+
2130
2129
if (!noctty &&
2131
2130
current -> signal -> leader &&
2132
2131
!current -> signal -> tty &&
0 commit comments