lkml.org 
[lkml]   [1997]   [Jul]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectWhat to do on ctrl-alt-del?
Hi,

if you call reboot(2) to disable ctrl-alt-del, SIGINT will be sent to
process 1 if the user presses ctrl-alt-del. This has been ok in the past
but since Linux has the unique initrd feature there is not always a
process with pid 1. As initrd is intended and used for installation
purposes it might be necessary to allow linuxrc to intercept ctr-alt-del;
otherwise the system immediately reboots upon that key combination without
a clean shutdown. Wouldn't it be correct to send SIGINT to the process
that disabled ctrl-alt-del? This little patch does this. There might be
additional use of this functionality. Any comments?

BTW: Shouldn't C_A_D be made static? Besides ./kernel/sys.c it is only
declared extern in ./kernel/panic.c but not used.

----------------------------------------------------------------------
diff -urN linux-pre-2.0.31-3/kernel/sys.c linux-pre-2.0.31-3-new/kernel/sys.c
--- linux-pre-2.0.31-3/kernel/sys.c Thu Jul 10 12:37:55 1997
+++ linux-pre-2.0.31-3-new/kernel/sys.c Fri Jul 11 17:56:13 1997
@@ -32,6 +32,7 @@
* this indicates whether you can reboot with ctrl-alt-del: the default is yes
*/
int C_A_D = 1;
+static int reboot_pid = 1; /* pid of process to send SIGINT when CAD disabled */

extern void adjust_clock(void);
extern void gdth_halt(void);
@@ -195,9 +196,10 @@
hard_reset_now();
} else if (flag == 0x89ABCDEF)
C_A_D = 1;
- else if (!flag)
+ else if (!flag) {
C_A_D = 0;
- else if (flag == 0xCDEF0123) {
+ reboot_pid = current->pid;
+ } else if (flag == 0xCDEF0123) {
printk(KERN_EMERG "System halted\n");
#ifdef __sparc__
halt_now();
@@ -225,7 +227,7 @@
#endif
hard_reset_now();
} else
- kill_proc(1, SIGINT, 1);
+ kill_proc(reboot_pid, SIGINT, 1);
}


----------------------------------------------------------------------
Hubert mantel@suse.de


\
 
 \ /
  Last update: 2005-03-22 13:39    [W:0.682 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site