TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: All
from: Craig Swanson
date: 1995-10-31 00:22:24
subject: DosShutdown( 1 )

I've encountered what I think may be a bug in the DosShutdown() API, but
would like some feedback from others regarding my thinking. I recall
reading that applications that want to sync the file systems to disk but
not shutdown the computer should issue a DosShutdown( 1 ) application
before they terminate.  Here is what the IBM Control Program Reference says
in the REMARKS section for the DosShutdown() API:

==========

  When ShutDownValue equals 0, the full system is shut down and the
  file-system is locked. In this case, DosShutdown can take several
  minutes to complete its operation; the time depends on the amount of
  data in the buffers.

  If other functions that change file-system data are issued while the
  system is shut down, either the return code ERROR_ALREADY_SHUTDOWN
  is set, or the other function calls are blocked permanently.

  Allocated memory cannot be increased once DosShutdown has been
  issued. This means that in low-memory situations, some functions may
  fail because of a lack of memory. This is of particular importance
  to the process issuing DosShutdown. All memory that the calling
  process will ever need should be allocated before DosShutdown is
  issued. This includes implicit memory allocations that system
  functions make on behalf of DosShutdown.

  When DosShutdown has completed successfully, the system can be
  powered-off or restarted.

  When ShutDownValue equals 1, the system is quiescent (no threads of
  execution are active) at the end of this function request, but the
  file-systems are not locked, and processing can resume at a later
  time.

========

Now that section about shutdown value being 1 seems to me to indicate that
after DosShutdown() runs, it should be possible to continue to run programs
without rebooting.  I vaguely recall reading about DosShutdown( 1 ) being
added around the time of OS/2 2.1 for the purpose of synchronizing file
systems to disk without taking down the entire system and thus requiring a
reboot.  The example I recall for a need for this is on notebook computers
which can be put in sleep mode.  Since my application is running on
notebook computers,I had added this call in just before the application
terminates.

What I have found is that if I issue DosShutdown( 1 ), it returns APIRET 0
(NO_ERROR).  However, it has apparently done something inside the kernel
that completely screws up DosResetBuffer(), at least as far as named pipes
calls are concerned.  After issuing a DosShutdown( 1 ), DosResetBuffer() no
longer blocks and any writes into a named pipe that may exceed the pipe
buffer size do not block but instead write only a fragment of the message
to be written,thus corrupting the named pipe buffers.

The only way to recover from this condition is to reboot the computer.

Has anybody else used some other way to sync file systems to disk on
notebook computers so they can be put to sleep without having to worry
about the file systems being messed up, thus requiring CHKDSK and possibly
loosing data, if they are turned off?  Or is DosShutdown( 1 ) the only way
to do this?


--- Maximus/2 2.02
* Origin: OS/2 Connection {at} Mira Mesa, CA (1:202/354)
SEEN-BY: 270/101 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407
SEEN-BY: 712/515 517 628 704 713/888 800/1 7877/2809
@PATH: 202/354 300 777 3615/50 396/1 270/101 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.