From 7988a44fbba6a8b9702420115754b0eae2c3ccdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Thu, 12 Sep 2002 21:53:32 +0000 Subject: [PATCH] cleanup, licence, notes git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1020 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/bin/shutdown.cpp | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/apps/bin/shutdown.cpp b/src/apps/bin/shutdown.cpp index 562836c1a0..5bf03438fc 100644 --- a/src/apps/bin/shutdown.cpp +++ b/src/apps/bin/shutdown.cpp @@ -1,3 +1,31 @@ +// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ +// +// Copyright (c) 2002, OpenBeOS +// +// This software is part of the OpenBeOS distribution and is covered +// by the OpenBeOS license. +// +// +// File: shutdown.cpp +// Author: Francois Revol (mmu_man@users.sf.net) +// Description: shuts down the system, either halting or rebooting. +// +// Notes: +// This program behaves identically as the BeOS R5 version, with these +// added arguments: +// +// -a alert user while counting down +// -c cancels any running shutdown +// +// There seem to be a race condition (sometimes crashes on quit with +// "the looper must be locked"), if you find it, tell me, +// tried 3 hours to find it. +// Some code from Shard's Archiver from BeBits (was BSD/MIT too :). +// +// Compile with: LDFLAGS="-lbe" make +// +// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + #include #include #include @@ -14,8 +42,6 @@ #include #include -// LDFLAGS="-lbe" make - //from bdb-ing /bin/shutdown: #define B_SYSTEM_SHUTDOWN 0x12d #define B_SYSTEM_REBOOT 0x12e @@ -164,7 +190,6 @@ SView::SView(BRect frame) *fTitleStr << "Rebooting in " << (int32)fTimeLeft << " seconds !"; else *fTitleStr << "Shutting down in " << (int32)fTimeLeft << " seconds !"; -// fTitle = new BStringView(BRect( fLeftMargin, fTopMargin, fLeftMargin, fTopMargin), "", fTitleStr->String()); fTitle = new BStringView(BRect(55, 10, 260, 35), "", fTitleStr->String()); fButton = new BButton(BRect(159, 42, 259, 66), "quit", "Cancel", new BMessage('_QRQ')); fButton->MakeDefault(true); @@ -206,7 +231,6 @@ SView::Draw(BRect updateRect) SetHighColor(tint_color(ViewColor(), B_HIGHLIGHT_BACKGROUND_TINT)); FillRect(BRect(0, 0, B_LARGE_ICON, bounds.bottom)); - // fIcon if any if(fIcon != NULL) { DrawBitmap(fIcon, BPoint( (B_LARGE_ICON / 2), fTopMargin)); @@ -283,6 +307,8 @@ int32 app_thread(void *arg) /***************************/ +// we get here when shutdown is cancelled. +// then sleep() returns void handle_usr1(int sig) { while (0); @@ -347,7 +373,7 @@ int main(int argc, char **argv) signal(SIGUSR1, handle_usr1); if (alert) { - puts("shutting down"); + // BApplication::Run() blocks BApp_thread = spawn_thread(app_thread, "BApplication", B_NORMAL_PRIORITY, (void *)find_thread(NULL)); resume_thread(BApp_thread); }