* 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:
Axel Dörfler
2010-04-30 07:13:21 +00:00
parent 2b1246262d
commit c71183bc8b
+21 -12
View File
@@ -1,13 +1,15 @@
/*
* Copyright 2002-2005, Haiku.
* Copyright 2002-2010, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Francois Revol ([email protected])
*/
/*! Shuts down the system, either halting or rebooting. */
#include <syscalls.h>
#include <OS.h>
@@ -21,12 +23,14 @@
#include <unistd.h>
#include <ctype.h>
uint32 gTimeToSleep = 0;
bool gReboot = false;
// we get here when shutdown is cancelled.
// then sleep() returns
/*! We get here when shutdown is cancelled.
Then sleep() returns.
*/
void
handle_usr1(int sig)
{
@@ -107,19 +111,23 @@ main(int argc, char **argv)
break;
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;
get_thread_info(find_thread(NULL), &threadInfo);
team_id thisTeam = threadInfo.team;
int32 team_cookie = 0;
team_info teamInfo;
while (get_next_team_info(&team_cookie, &teamInfo) == B_OK) {
if (strstr(teamInfo.args, "shutdown") != NULL && teamInfo.team != thisTeam) {
while (get_next_team_info(&team_cookie, &teamInfo)
== B_OK) {
if (strstr(teamInfo.args, "shutdown") != NULL
&& teamInfo.team != thisTeam) {
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"))
kill(threadInfo.thread, SIGUSR1);
}
@@ -148,7 +156,8 @@ main(int argc, char **argv)
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);
@@ -162,7 +171,7 @@ main(int argc, char **argv)
#ifdef __HAIKU__
_kern_shutdown(gReboot);
#endif // __HAIKU__
fprintf(stderr, "Shutdown failed!\n");
fprintf(stderr, "Shutdown failed! (Do you have ACPI enabled?)\n");
return 2;
} else {
BRoster roster;