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)
540
540
541
541
EXPORT_SYMBOL_GPL (tty_wakeup );
542
542
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
+
543
565
/**
544
566
* __tty_hangup - actual handler for hangup events
545
567
* @tty: tty device
@@ -566,21 +588,15 @@ EXPORT_SYMBOL_GPL(tty_wakeup);
566
588
static void __tty_hangup (struct tty_struct * tty , int exit_session )
567
589
{
568
590
struct file * cons_filp = NULL ;
569
- struct file * filp , * f = NULL ;
591
+ struct file * filp , * f ;
570
592
struct tty_file_private * priv ;
571
593
int closecount = 0 , n ;
572
594
int refs ;
573
595
574
596
if (!tty )
575
597
return ;
576
598
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 );
584
600
585
601
tty_lock (tty );
586
602
Original file line number Diff line number Diff line change @@ -421,6 +421,7 @@ extern void tty_kclose(struct tty_struct *tty);
421
421
extern int tty_dev_name_to_number (const char * name , dev_t * number );
422
422
extern int tty_ldisc_lock (struct tty_struct * tty , unsigned long timeout );
423
423
extern void tty_ldisc_unlock (struct tty_struct * tty );
424
+ extern struct file * tty_release_redirect (struct tty_struct * tty );
424
425
#else
425
426
static inline void tty_kref_put (struct tty_struct * tty )
426
427
{ }
You can’t perform that action at this time.
0 commit comments