2005-01-07 13:37:09

by Marco Cipullo

[permalink] [raw]
Subject: In last setsid/tty locking changes...

In last setsid/tty locking changes:

diff -Nru a/kernel/exit.c b/kernel/exit.c
--- a/kernel/exit.c 2005-01-07 05:24:41 -08:00
+++ b/kernel/exit.c 2005-01-07 05:24:41 -08:00
@@ -332,7 +332,9 @@
exit_mm(current);

set_special_pids(1, 1);
+ down(&tty_sem);
current->signal->tty = NULL;
+ up(&tty_sem);

/* Block and flush all signals */
sigfillset(&blocked);

Sorry for the silly question, but why is needed a semaphore to write just one
value without read/write nothing else?

Bye
Marco


2005-01-07 16:50:00

by Alan

[permalink] [raw]
Subject: Re: In last setsid/tty locking changes...

On Gwe, 2005-01-07 at 13:37, Marco Cipullo wrote:
> In last setsid/tty locking changes:
> + down(&tty_sem);
> current->signal->tty = NULL;
> + up(&tty_sem);
>
> /* Block and flush all signals */
> sigfillset(&blocked);
>
> Sorry for the silly question, but why is needed a semaphore to write just one
> value without read/write nothing else?

Look at the tty init_dev code paths and it might make more sense. It
doesn't just say "protect this write" more importantly it says "don't do
this in parallel with tty setup"