Re: reboot -p

2001-12-27 Thread Poul-Henning Kamp

In message [EMAIL PROTECTED], Thomas Quinot wri
tes:
Currently, when reboot is invoked with the '-p' command line flag
(powerdown), it performs a shutdown with RB_HALT|RB_POWEROFF.
In some situations, it can be useful to try to perform a poweroff,
but reboot if it fails (e.g. when you are shutting down the system
as a result of a power failure, you want the system to reboot,
*not* stay down, if power was restored after the start of the shutdown
procedure). It would be nice if reboot was changed to pass only
RB_POWEROFF (without RB_HALT) when invoked with '-p'. Of course halt(8)
whould be unaffected and still pass RB_HALT|RB_POWEROFF when invoked
as halt -p.

What do others think of this change:

Sounds reasonable.

-- 
Poul-Henning Kamp   | UNIX since Zilog Zeus 3.20
[EMAIL PROTECTED] | TCP/IP since RFC 956
FreeBSD committer   | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-current in the body of the message



Re: reboot -p

2001-12-27 Thread Garance A Drosihn

Thomas Quinot writes:
  Currently, when reboot is invoked with the '-p' command line flag
  (powerdown), it performs a shutdown with RB_HALT|RB_POWEROFF.
  In some situations, it can be useful to try to perform a poweroff,
  but reboot if it fails (e.g. when you are shutting down the system
  as a result of a power failure, you want the system to reboot,
   *not* stay down, if power was restored after the start of the
   shutdown procedure). It would be nice if reboot was changed to
   pass only RB_POWEROFF (without RB_HALT) when invoked with '-p'.
   Of course halt(8) would be unaffected and still pass
   RB_HALT|RB_POWEROFF when invoked as halt -p.
  
  What do others think of this change:

If I understand what you are saying, the situation that you describe
seems odd to me.  If I do the command:
   shutdown -p now Power Failure\!
then I expect the machine to power-off if possible, or at least
halt if a power-off is not possible.  Why would I want it to
immediately reboot in that situation?

If I understand your request, you would want
   shutdown -p now
to behave the same as
   shutdown -r now
if the operating system does not know how to power down the hardware.
Is that what you want?

I guess I don't object to that, if that's what you want, but it does
seem a little odd to me.  I assume that an explicit
  shutdown -h -p now
would still halt the machine if the OS doesn't know how to power off
the machine.   By the way, what happens right now if someone does a
  shutdown -r -p now
?  Does that behave the way you want for your situation?

-- 
Garance Alistair Drosehn=   [EMAIL PROTECTED]
Senior Systems Programmer   or  [EMAIL PROTECTED]
Rensselaer Polytechnic Instituteor  [EMAIL PROTECTED]

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-current in the body of the message



Re: reboot -p

2001-12-27 Thread Thomas Quinot

Le 2001-12-27, Garance A Drosihn écrivait :

 If I understand your request, you would want
shutdown -p now
 to behave the same as
shutdown -r now
 if the operating system does not know how to power down the hardware.
 Is that what you want?

Actually what I want would be more like support for a combination like:
shutdown -r -p now
(which is currently unsupported because we have assigned one signal
that says init 'shutdown -r' and another for 'shutdown -p', but that's
not the issue here.)

More precisely, right now if you do
reboot -p
then you have exactly the same behaviour as
halt -p
I.e. try to power down the system, and if the power down fails, then
halt.

What I would like to have is a means to try to powerdown the system,
and if the powerdown fails, then reboot. This comes in handy in the
following scenario:
1. UPS signals impending low battery condition;
2. UPS monitoring daemon starts shutdown;
3. kernel syncs buffers and umounts file systems;
4. using an ad hoc event handler registered in shutdown_final,
   we then signal the UPS that it can stop outputting AC from
   the battery backup (this is the powerdown action);

If the UPS is still on battery power at stage 4, then it will actually
power down the machine. On the other hand, if power was restored after
stage 2 (eg while the kernel was flushing its buffers), then the
signalling at stage 4 will have no effect and the machine needs to
reboot.

An alternative solution is to make a special-purpose binary that calls
shutdown(2) with RB_POWER set and RB_HALT cleared, or to use a different
method altogether for starting that emergency powerdown/reboot sequence.
On the other hand, it seems to me that RB_POWER should be the proper way
of requesting a powerdown action from the kernel.

Thomas.

-- 
[EMAIL PROTECTED]

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-current in the body of the message



reboot -p

2001-12-26 Thread Thomas Quinot

Currently, when reboot is invoked with the '-p' command line flag
(powerdown), it performs a shutdown with RB_HALT|RB_POWEROFF.
In some situations, it can be useful to try to perform a poweroff,
but reboot if it fails (e.g. when you are shutting down the system
as a result of a power failure, you want the system to reboot,
*not* stay down, if power was restored after the start of the shutdown
procedure). It would be nice if reboot was changed to pass only
RB_POWEROFF (without RB_HALT) when invoked with '-p'. Of course halt(8)
whould be unaffected and still pass RB_HALT|RB_POWEROFF when invoked
as halt -p.

What do others think of this change:

--- reboot.cThu Aug  2 12:01:20 2001
+++ /tmp/reboot.c   Wed Dec 26 13:03:45 2001
@@ -93,7 +93,7 @@
break;
case 'p':
pflag = 1;
-   howto |= (RB_POWEROFF | RB_HALT);
+   howto |= RB_POWEROFF;
break;
case 'q':
qflag = 1;

-- 
[EMAIL PROTECTED]

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-current in the body of the message