lkml.org 
[lkml]   [2006]   [Jun]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subjectemergency or init=/bin/sh mode and terminal signals
Hi,

There's a long-standing issue in init=/bin/sh mode: pressing control-C
doesn't send a SIGINT to programs running on the console. The incurred
typical pitfall is if one runs ping without a -c option... no way to
stop it!

This is because no session is set up by the kernel, and shells don't
start sessions on their own, so that no session (hence no controlling
tty) is set up.

The attached patch sets such session and controlling tty up, which fixes
the issue. The unfortunate effect is that init might be killed if one
presses control-C very fast after its start.

Samuel
--- linux-2.6.17-orig/init/main.c 2006-06-18 19:22:40.000000000 +0200
+++ linux-2.6.17-perso/init/main.c 2006-06-18 23:00:00.000000000 +0200
@@ -703,9 +703,13 @@
system_state = SYSTEM_RUNNING;
numa_default_policy();

+ sys_setsid();
+
if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
printk(KERN_WARNING "Warning: unable to open an initial console.\n");

+ sys_ioctl(0, TIOCSCTTY, 1);
+
(void) sys_dup(0);
(void) sys_dup(0);
\
 
 \ /
  Last update: 2006-06-18 23:25    [W:0.174 / U:1.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site