bdflush & setsid - Kernel v2.1.77+

Jason McMullan (jmcc@pepsi.visus.com)
18 Feb 1998 21:34:10 GMT


There appears to be a bug in init/main.c that [due to recent scheduler
changes, and the massive number of printks that my devel kernel
is emitting] leaves the init() process without access to /dev/tty.
Here's how:

a) init/main.c:init() gets called
b) kernel_thread(bdflush) starts
c) misc setup stuff happens
d) /dev/console is opened
e) execv("/bin/init","init");

At step (c), what happens if bdflush() sets it's process group to 1?
(pid of init) That means that when setsid() is called in do_initrd,
is _fails_, because there already exists a task (bdflush) with a
process group == current->pid.

And if that happens, current->leader == 0, when means that
drivers/char/tty_io.c:tiocsctty() fails, and /dev/tty cannot
be opened by /sbin/init.

The simple fix is to call setsid() before forking off
kernel_thread("bdflush",...) at the top of init/main.c:init()

I racked my brains for two weeks on this one - I could
boot up multiuser just fine, but LILO: linux init=/bin/sh would
leave me with a system that simply echoed what I typed,
since /bin/sh couldn't open /dev/tty to read my commands
or write output.

Has anyone else noticed this?

-- 
Jason McMullan - Linux - GGI - http://beans.visus.com/~jmcc
NT 5.0 is the last nail in the Unix coffin. Interestingly, Unix
isn't in the coffin... It's wondering what the heck is sealing 
itself into a wooden box 6 feet underground... 

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu