* Added the text "(Do you have ACPI enabled?)" in case -q failed.
* Minor coding style cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36547 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+21
-12
@@ -1,13 +1,15 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2005, Haiku.
|
* Copyright 2002-2010, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Francois Revol ([email protected])
|
* Francois Revol ([email protected])
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*! Shuts down the system, either halting or rebooting. */
|
/*! Shuts down the system, either halting or rebooting. */
|
||||||
|
|
||||||
|
|
||||||
#include <syscalls.h>
|
#include <syscalls.h>
|
||||||
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
@@ -21,12 +23,14 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
|
||||||
uint32 gTimeToSleep = 0;
|
uint32 gTimeToSleep = 0;
|
||||||
bool gReboot = false;
|
bool gReboot = false;
|
||||||
|
|
||||||
// we get here when shutdown is cancelled.
|
|
||||||
// then sleep() returns
|
|
||||||
|
|
||||||
|
/*! We get here when shutdown is cancelled.
|
||||||
|
Then sleep() returns.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
handle_usr1(int sig)
|
handle_usr1(int sig)
|
||||||
{
|
{
|
||||||
@@ -107,19 +111,23 @@ main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
{
|
{
|
||||||
// find all running shutdown command and signal its shutdown thread
|
// find all running shutdown commands and signal their
|
||||||
|
// shutdown threads
|
||||||
|
|
||||||
thread_info threadInfo;
|
thread_info threadInfo;
|
||||||
get_thread_info(find_thread(NULL), &threadInfo);
|
get_thread_info(find_thread(NULL), &threadInfo);
|
||||||
|
|
||||||
team_id thisTeam = threadInfo.team;
|
team_id thisTeam = threadInfo.team;
|
||||||
|
|
||||||
int32 team_cookie = 0;
|
int32 team_cookie = 0;
|
||||||
team_info teamInfo;
|
team_info teamInfo;
|
||||||
while (get_next_team_info(&team_cookie, &teamInfo) == B_OK) {
|
while (get_next_team_info(&team_cookie, &teamInfo)
|
||||||
if (strstr(teamInfo.args, "shutdown") != NULL && teamInfo.team != thisTeam) {
|
== B_OK) {
|
||||||
|
if (strstr(teamInfo.args, "shutdown") != NULL
|
||||||
|
&& teamInfo.team != thisTeam) {
|
||||||
int32 thread_cookie = 0;
|
int32 thread_cookie = 0;
|
||||||
while (get_next_thread_info(teamInfo.team, &thread_cookie, &threadInfo) == B_OK) {
|
while (get_next_thread_info(teamInfo.team,
|
||||||
|
&thread_cookie, &threadInfo) == B_OK) {
|
||||||
if (!strcmp(threadInfo.name, "shutdown"))
|
if (!strcmp(threadInfo.name, "shutdown"))
|
||||||
kill(threadInfo.thread, SIGUSR1);
|
kill(threadInfo.thread, SIGUSR1);
|
||||||
}
|
}
|
||||||
@@ -148,7 +156,8 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
signal(SIGUSR1, handle_usr1);
|
signal(SIGUSR1, handle_usr1);
|
||||||
|
|
||||||
printf("Delaying %s by %lu seconds...\n", gReboot ? "reboot" : "shutdown", gTimeToSleep);
|
printf("Delaying %s by %lu seconds...\n",
|
||||||
|
gReboot ? "reboot" : "shutdown", gTimeToSleep);
|
||||||
|
|
||||||
left = sleep(gTimeToSleep);
|
left = sleep(gTimeToSleep);
|
||||||
|
|
||||||
@@ -162,7 +171,7 @@ main(int argc, char **argv)
|
|||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
_kern_shutdown(gReboot);
|
_kern_shutdown(gReboot);
|
||||||
#endif // __HAIKU__
|
#endif // __HAIKU__
|
||||||
fprintf(stderr, "Shutdown failed!\n");
|
fprintf(stderr, "Shutdown failed! (Do you have ACPI enabled?)\n");
|
||||||
return 2;
|
return 2;
|
||||||
} else {
|
} else {
|
||||||
BRoster roster;
|
BRoster roster;
|
||||||
|
|||||||
Reference in New Issue
Block a user