Groups | Search | Server Info | Login | Register


Groups > comp.os.os2.programmer.misc > #1594

How do safe shutdown programmatically?

From "Andi B." <andi.b@gmx.net>
Newsgroups comp.os.os2.programmer.misc
Subject How do safe shutdown programmatically?
Date 2017-10-29 13:01 +0100
Organization A noiseless patient Spider
Message-ID <ot4cde$or0$1@dont-email.me> (permalink)

Show all headers | View raw


Hi,
I want to shut down the system from my program. I can do it the ACPI toolkit way -

AcpiTkPrepareToSleep(ACPI_STATE_S5);
rc = DosShutdown(0L);
DosSleep(3000); /* Wait allows shutdown to complete */
rc = AcpiTkGoToSleep(&Hdl, ACPI_STATE_S5);

But PowerOff.c still states 'Created 2005  eCo Software'. I'm pretty sure the code is 
changed by David afterwards but usually when he does he adds name and date. So I'm not 
sure if this is really the latest and best way to shut down / power off. Moreover this 
code does shut down my T60 so fast that I think running application may not have a chance 
to properly close down and save files before shutting down.

I want a clean shut down like xwp extended shutdown feature. With all application closes 
cleanly. So I guess I could call some xwp code to to it for me. But how to do? Is there a 
xwp api to start extended shut down?

If I would send a WM_QUIT myself to all running programs I think this would be reinventing 
the wheel again. On the other hand if I would let some other program send WM_QUIT to all 
programs, my own program will get it too and may close before I can AcpiTkGoToSleep. I 
would need to assure my program is the last one which is closed in this scenario.

I can call some system(shutdown.exe). But which one is the best? I tried the default on my 
T60 installation (upgraded eCS2.x) and it end up with the message box - shutdown completed 
you can now power off the system. But I don't want to power off by myself. That's the task 
of ACPI (APM on older systems).

AcpiStat poweroff does the same as the Acpi toolkit poweroff. At least when looking at the 
sources from -
* Rewritten by: David Azarewicz
* Copyright (c) 2011-2012 Mensys BV

No clue where I got it. Are there newer versions available?

Any thoughts welcome.

Andreas

Back to comp.os.os2.programmer.misc | Previous | Next | Find similar


Thread

How do safe shutdown programmatically? "Andi B." <andi.b@gmx.net> - 2017-10-29 13:01 +0100

csiph-web