Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 54610
b: refs/heads/master
c: 2a65f1d
h: refs/heads/master
v: v3
  • Loading branch information
Eric W. Biederman authored and Linus Torvalds committed May 8, 2007
1 parent 686e7f6 commit 77e795e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f67c3627b4abd8a3cf56bd20cafde702feffe236
refs/heads/master: 2a65f1d9fe78475720bd8f0e0fbbf1973b1b5ac2
23 changes: 6 additions & 17 deletions trunk/drivers/char/tty_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ int tty_ioctl(struct inode * inode, struct file * file,
unsigned int cmd, unsigned long arg);
static int tty_fasync(int fd, struct file * filp, int on);
static void release_tty(struct tty_struct *tty, int idx);
static struct pid *__proc_set_tty(struct task_struct *tsk,
struct tty_struct *tty);
static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty);

/**
* alloc_tty_struct - allocate a tty object
Expand Down Expand Up @@ -1532,10 +1531,9 @@ void disassociate_ctty(int on_exit)
}

spin_lock_irq(&current->sighand->siglock);
tty_pgrp = current->signal->tty_old_pgrp;
put_pid(current->signal->tty_old_pgrp);
current->signal->tty_old_pgrp = NULL;
spin_unlock_irq(&current->sighand->siglock);
put_pid(tty_pgrp);

mutex_lock(&tty_mutex);
/* It is possible that do_tty_hangup has free'd this tty */
Expand Down Expand Up @@ -2506,7 +2504,6 @@ static int tty_open(struct inode * inode, struct file * filp)
int index;
dev_t device = inode->i_rdev;
unsigned short saved_flags = filp->f_flags;
struct pid *old_pgrp;

nonseekable_open(inode, filp);

Expand Down Expand Up @@ -2600,17 +2597,15 @@ static int tty_open(struct inode * inode, struct file * filp)
goto retry_open;
}

old_pgrp = NULL;
mutex_lock(&tty_mutex);
spin_lock_irq(&current->sighand->siglock);
if (!noctty &&
current->signal->leader &&
!current->signal->tty &&
tty->session == NULL)
old_pgrp = __proc_set_tty(current, tty);
__proc_set_tty(current, tty);
spin_unlock_irq(&current->sighand->siglock);
mutex_unlock(&tty_mutex);
put_pid(old_pgrp);
return 0;
}

Expand Down Expand Up @@ -3835,31 +3830,25 @@ void proc_clear_tty(struct task_struct *p)
spin_unlock_irq(&p->sighand->siglock);
}

static struct pid *__proc_set_tty(struct task_struct *tsk, struct tty_struct *tty)
static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty)
{
struct pid *old_pgrp;
if (tty) {
/* We should not have a session or pgrp to here but.... */
put_pid(tty->session);
put_pid(tty->pgrp);
tty->session = get_pid(task_session(tsk));
tty->pgrp = get_pid(task_pgrp(tsk));
}
old_pgrp = tsk->signal->tty_old_pgrp;
put_pid(tsk->signal->tty_old_pgrp);
tsk->signal->tty = tty;
tsk->signal->tty_old_pgrp = NULL;
return old_pgrp;
}

void proc_set_tty(struct task_struct *tsk, struct tty_struct *tty)
{
struct pid *old_pgrp;

spin_lock_irq(&tsk->sighand->siglock);
old_pgrp = __proc_set_tty(tsk, tty);
__proc_set_tty(tsk, tty);
spin_unlock_irq(&tsk->sighand->siglock);

put_pid(old_pgrp);
}

struct tty_struct *get_current_tty(void)
Expand Down

0 comments on commit 77e795e

Please sign in to comment.