shutdown now defaults to returning to the caller (ie. runs asynchronously), as it
does in BeOS. If you want it to wait until the shutdown process fails (or the system is actually shut down), use the new "-s" option. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15923 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+17
-23
@@ -1,24 +1,12 @@
|
|||||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
/*
|
||||||
//
|
* Copyright 2002-2005, Haiku.
|
||||||
// Copyright (c) 2002-2005, Haiku
|
* Distributed under the terms of the MIT License.
|
||||||
//
|
*
|
||||||
// This software is part of the Haiku distribution and is covered
|
* Authors:
|
||||||
// by the MIT license.
|
* Francois Revol ([email protected])
|
||||||
//
|
*/
|
||||||
// File: shutdown.cpp
|
|
||||||
// Author: Francois Revol ([email protected])
|
/*! Shuts down the system, either halting or rebooting. */
|
||||||
// Description: shuts down the system, either halting or rebooting.
|
|
||||||
//
|
|
||||||
// Notes:
|
|
||||||
// This program behaves identically as the BeOS R5 version, with these
|
|
||||||
// added arguments:
|
|
||||||
//
|
|
||||||
// -a asks the user to confirm the shutdown
|
|
||||||
// -c cancels any running shutdown
|
|
||||||
//
|
|
||||||
// Some code from Shard's Archiver from BeBits (was BSD/MIT too :).
|
|
||||||
//
|
|
||||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
|
||||||
|
|
||||||
#include <syscalls.h>
|
#include <syscalls.h>
|
||||||
|
|
||||||
@@ -84,6 +72,7 @@ usage(const char *arg0)
|
|||||||
"\t-q quick shutdown (don't broadcast apps),\n"
|
"\t-q quick shutdown (don't broadcast apps),\n"
|
||||||
"\t-a ask user to confirm the shutdown (ignored when -q is given),\n"
|
"\t-a ask user to confirm the shutdown (ignored when -q is given),\n"
|
||||||
"\t-c cancel a running shutdown,\n"
|
"\t-c cancel a running shutdown,\n"
|
||||||
|
"\t-s run shutdown synchronously (only returns if shutdown is cancelled)\n"
|
||||||
"\t-d delay shutdown by <time> seconds.\n", program);
|
"\t-d delay shutdown by <time> seconds.\n", program);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -94,6 +83,7 @@ main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
bool askUser = false;
|
bool askUser = false;
|
||||||
bool quick = false;
|
bool quick = false;
|
||||||
|
bool async = true;
|
||||||
|
|
||||||
for (int32 i = 1; i < argc; i++) {
|
for (int32 i = 1; i < argc; i++) {
|
||||||
char *arg = argv[i];
|
char *arg = argv[i];
|
||||||
@@ -112,6 +102,9 @@ main(int argc, char **argv)
|
|||||||
case 'r':
|
case 'r':
|
||||||
gReboot = true;
|
gReboot = true;
|
||||||
break;
|
break;
|
||||||
|
case 's':
|
||||||
|
async = false;
|
||||||
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
{
|
{
|
||||||
// find all running shutdown command and signal its shutdown thread
|
// find all running shutdown command and signal its shutdown thread
|
||||||
@@ -174,8 +167,9 @@ main(int argc, char **argv)
|
|||||||
} else {
|
} else {
|
||||||
BRoster roster;
|
BRoster roster;
|
||||||
BRoster::Private rosterPrivate(roster);
|
BRoster::Private rosterPrivate(roster);
|
||||||
status_t error = rosterPrivate.ShutDown(gReboot, askUser, true);
|
status_t error = rosterPrivate.ShutDown(gReboot, askUser, !async);
|
||||||
fprintf(stderr, "Shutdown failed: %s\n", strerror(error));
|
if (error != B_OK)
|
||||||
|
fprintf(stderr, "Shutdown failed: %s\n", strerror(error));
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user