public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Console: fall back to /dev/null when no console is availlable
@ 2004-10-05 18:52 Jörn Engel
  2004-10-05 20:27 ` Russell King
                   ` (4 more replies)
  0 siblings, 5 replies; 45+ messages in thread
From: Jörn Engel @ 2004-10-05 18:52 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

Looks pretty trivial, but opinions on this subject may vary.
Comments?

Jörn

-- 
More computing sins are committed in the name of efficiency (without
necessarily achieving it) than for any other single reason - including
blind stupidity.
-- W. A. Wulf 

Some userspace applications rely on the assumption that fd's 0, 1 and
2 are always open and function as raw stdin, stdout and stderr,
respectively.

With no console registered, init get's called without those fd's
already open.  Arguably, init should know better, handle that case and
fix things before forking other processed.  But what about
init=/bin/bash?  Ok, bash could be fixed as well, as could...

Instead, this patch opens /dev/null when /dev/console doesn't work.
It swallows all output and doesn't give much input, but programs can
handle that just fine.

Signed-off-by: Jörn Engel <joern@wohnheim.fh-wedel.de>
---

 main.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletion(-)

--- linux-2.6.8cow/init/main.c~console	2004-10-05 20:46:40.000000000 +0200
+++ linux-2.6.8cow/init/main.c	2004-10-05 20:46:08.000000000 +0200
@@ -695,8 +695,11 @@
 	system_state = SYSTEM_RUNNING;
 	numa_default_policy();
 
-	if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
+	if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0) {
 		printk("Warning: unable to open an initial console.\n");
+		if (open("/dev/null", O_RDWR, 0) == 0)
+			printk("         Falling back to /dev/null.\n");
+	}
 
 	(void) sys_dup(0);
 	(void) sys_dup(0);

^ permalink raw reply	[flat|nested] 45+ messages in thread

end of thread, other threads:[~2004-10-08  2:22 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-05 18:52 [PATCH] Console: fall back to /dev/null when no console is availlable Jörn Engel
2004-10-05 20:27 ` Russell King
2004-10-05 21:06   ` Greg KH
2004-10-05 21:13     ` Russell King
2004-10-06 15:00       ` Alan Cox
2004-10-06 17:41         ` Greg KH
2004-10-06 18:01           ` Jörn Engel
2004-10-06 18:18             ` Greg KH
2004-10-06 19:20               ` Jörn Engel
2004-10-06 18:26             ` Chris Wright
2004-10-06 18:16           ` Andries Brouwer
2004-10-06 19:18           ` Alan Cox
2004-10-06 20:54             ` Greg KH
2004-10-06 20:29               ` Alan Cox
2004-10-06 21:45                 ` Russell King
2004-10-07  5:51                 ` Valdis.Kletnieks
2004-10-08  2:15                   ` Herbert Xu
2004-10-06 20:01           ` Russell King
2004-10-05 22:36   ` Andries Brouwer
2004-10-06  6:43     ` Russell King
2004-10-07 14:41   ` Jan-Benedict Glaw
2004-10-05 21:58 ` Denis Vlasenko
2004-10-06  4:34   ` Willy Tarreau
2004-10-06  8:43     ` Geert Uytterhoeven
2004-10-06 12:15       ` Jörn Engel
2004-10-06 13:07         ` Geert Uytterhoeven
2004-10-06 13:33           ` Jörn Engel
2004-10-06 13:55             ` Geert Uytterhoeven
2004-10-06 14:12               ` Jörn Engel
2004-10-06 14:23                 ` Geert Uytterhoeven
2004-10-06 15:28                   ` Jörn Engel
2004-10-06 15:36                     ` Geert Uytterhoeven
2004-10-06 15:51                       ` Jörn Engel
2004-10-05 23:30 ` Andrew Morton
2004-10-06 12:16   ` Jörn Engel
2004-10-06 17:38 ` Greg KH
2004-10-06 18:04   ` Jörn Engel
2004-10-06 18:19     ` Greg KH
2004-10-06 19:23       ` Jörn Engel
2004-10-06 21:22         ` Thayne Harbaugh
2004-10-07  8:18           ` Geert Uytterhoeven
2004-10-07  9:07             ` Russell King
2004-10-07  9:46               ` Geert Uytterhoeven
2004-10-06 18:37 ` Gianni Tedesco
2004-10-06 19:08   ` Jörn Engel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox