When the halt command is called with the -p flag (or as poweroff)
the command now passes the "-h -P" flags to shutdown. This in turn sets the INIT_HALT environment variable to POWEROFF. Assuming this value is checked by initscripts during the shutting down procedure, it should cause the system to be powered off. If halt is called without -p then the value of INIT_HALT is not set and the default action (often set in /etc/defaut/halt) is taken.
This commit is contained in:
1 parent
c03e2fac2b
commit
f0e93128bc
2 files changed
+14
-3
No files matched your search
+5
-3
@@ -155,13 +155,15 @@ int get_runlevel(void)
|
||||
/*
|
||||
* Switch to another runlevel.
|
||||
*/
|
||||
void do_shutdown(char *fl, char *tm)
|
||||
void do_shutdown(char *fl, int should_poweroff, char *tm)
|
||||
{
|
||||
char *args[8];
|
||||
char *args[9];
|
||||
int i = 0;
|
||||
|
||||
args[i++] = "shutdown";
|
||||
args[i++] = fl;
|
||||
if ( (! strcmp(fl, "-h") ) && (should_poweroff) )
|
||||
args[i++] = "-P";
|
||||
if (tm) {
|
||||
args[i++] = "-t";
|
||||
args[i++] = tm;
|
||||
@@ -259,7 +261,7 @@ int main(int argc, char **argv)
|
||||
*/
|
||||
c = get_runlevel();
|
||||
if (c != '0' && c != '6')
|
||||
do_shutdown(do_reboot ? "-r" : "-h", tm);
|
||||
do_shutdown(do_reboot ? "-r" : "-h", do_poweroff, tm);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in new issue
Block a user