File tree Expand file tree Collapse file tree 2 files changed +25
-8
lines changed Expand file tree Collapse file tree 2 files changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -540,6 +540,28 @@ void tty_wakeup(struct tty_struct *tty)
540540
541541EXPORT_SYMBOL_GPL (tty_wakeup );
542542
543+ /**
544+ * tty_release_redirect - Release a redirect on a pty if present
545+ * @tty: tty device
546+ *
547+ * This is available to the pty code so if the master closes, if the
548+ * slave is a redirect it can release the redirect.
549+ */
550+ struct file * tty_release_redirect (struct tty_struct * tty )
551+ {
552+ struct file * f = NULL ;
553+
554+ spin_lock (& redirect_lock );
555+ if (redirect && file_tty (redirect ) == tty ) {
556+ f = redirect ;
557+ redirect = NULL ;
558+ }
559+ spin_unlock (& redirect_lock );
560+
561+ return f ;
562+ }
563+ EXPORT_SYMBOL_GPL (tty_release_redirect );
564+
543565/**
544566 * __tty_hangup - actual handler for hangup events
545567 * @tty: tty device
@@ -566,21 +588,15 @@ EXPORT_SYMBOL_GPL(tty_wakeup);
566588static void __tty_hangup (struct tty_struct * tty , int exit_session )
567589{
568590 struct file * cons_filp = NULL ;
569- struct file * filp , * f = NULL ;
591+ struct file * filp , * f ;
570592 struct tty_file_private * priv ;
571593 int closecount = 0 , n ;
572594 int refs ;
573595
574596 if (!tty )
575597 return ;
576598
577-
578- spin_lock (& redirect_lock );
579- if (redirect && file_tty (redirect ) == tty ) {
580- f = redirect ;
581- redirect = NULL ;
582- }
583- spin_unlock (& redirect_lock );
599+ f = tty_release_redirect (tty );
584600
585601 tty_lock (tty );
586602
Original file line number Diff line number Diff line change @@ -421,6 +421,7 @@ extern void tty_kclose(struct tty_struct *tty);
421421extern int tty_dev_name_to_number (const char * name , dev_t * number );
422422extern int tty_ldisc_lock (struct tty_struct * tty , unsigned long timeout );
423423extern void tty_ldisc_unlock (struct tty_struct * tty );
424+ extern struct file * tty_release_redirect (struct tty_struct * tty );
424425#else
425426static inline void tty_kref_put (struct tty_struct * tty )
426427{ }
You can’t perform that action at this time.
0 commit comments