This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

shutdown-1.3-1 patch for Win9x


Although shutdown.exe works fine on NT (XP at least), it's not possible to
shutdown a system to a power off state with shutdown.exe on Win9x
(Win98SE tested).

It's been my experience (on Win98SE anyway) that it's directly related
to the ShutdownEx() API. Despite what the API docs say, EWX_POWEROFF
actually performs a log off, while EWX_SHUTDOWN performs a power off
shutdown, on Win9x. This behavour seems to hold true even in a non
cygwin application.

The following patch to shutdown-1.3-1 makes 'shutdown -s' work as
expected (power off, instead of log off) on Win9x, tested on Win98SE.

Mark.

diff -up shutdown-1.3-1/shutdown.c shutdown-1.3-1.patch/shutdown.c
--- shutdown-1.3-1/shutdown.c 2003-05-26 05:39:08.000000000 +1000
+++ shutdown-1.3-1.patch/shutdown.c 2003-09-13 15:18:12.000000000 +1000
@@ -141,6 +141,9 @@ main (int argc, char **argv)
   char buf[4096], *arg, *endptr;
   DWORD err;

+  if(!is_winnt)
+    action = EWX_SHUTDOWN;
+
   if ((myname = strrchr (argv[0], '/')) || (myname = strrchr (argv[0], '\\')))
     ++myname;
   else
@@ -162,7 +165,10 @@ main (int argc, char **argv)
     force = EWX_FORCE;
   break;
       case 's':
-        action = EWX_POWEROFF;
+  if(is_winnt)
+          action = EWX_POWEROFF;
+  else
+    action = EWX_SHUTDOWN;
   break;
       case 'r':
   action = EWX_REBOOT;
@@ -260,7 +266,8 @@ main (int argc, char **argv)
   
   while (secs)
     secs = sleep (secs);
-  if (action == EWX_POWEROFF || action == EWX_REBOOT)
+  if ( (is_winnt && action == EWX_POWEROFF) ||
+       (!is_winnt && action == EWX_SHUTDOWN) || action == EWX_REBOOT)
     { 
       if (ExitWindowsEx (action | force, 0))
         return 0;
@@ -277,6 +284,7 @@ main (int argc, char **argv)
   switch (action)
     {
     case EWX_POWEROFF:
+    case EWX_SHUTDOWN:
       fprintf (stderr, "shutdown");
       break;
     case EWX_REBOOT:


-- 
Mark Ord                               | I tried my best, tried to forget,
Melbourne, Australia                   | that you're a bad habit, just like a
mailto://ord@alphalink.com.au          | cigarette.
http://www.alphalink.com.au/~ord/home/ | "Spark"         - Jesse Valenzuela -


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]