Prev: VECTORCAST
Next: COMP.DSP 2010 conference update
From: Tim Wescott on 17 Mar 2010 20:14 Tom wrote: > Tim Wescott wrote: >> D Yuniskis wrote: >>> Hi Jim, >>> >>> Jim Stewart wrote: >>>> I know that if you push the power button on a >>>> running PC, the machine does not power down >>>> until the OS has done its shutdown silly walk. >>> >>> I think a "short" press causes that response. >>> IIRC, the "hold for 4 seconds" behavior is done >>> in hardware (to deal with the problem of a hung >>> processor). I *vaguely* remember that from designing >>> with COMBO chips in years past (I suspect most of those >>> are no longer made as the floppy is a thing of the past) >>> >>>> Are there software hooks that allow an application >>>> to shutdown in an orderly fashion first? >>> >>> Depends on the operating system. Of course, the application >>> doesn't have to heed these warnings... >> >> I think it's 10 seconds. >> >> And yes, if you're not doing a hard power-down the OS will tap the >> applications on the shoulder, and point to the exit sign. >> > > Be aware that in Windows some applications may refuse and OS will not > shut down. We had to look for a workaround for UPS to shutdown a PC with > Citect Scada running on it. Yup. Usually you count to ten seconds by going "one thousand one, one thousand two, ...". With Windows and the power button it's "goddammit one, goddammit two, ...". -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com
From: Charles Gardiner on 17 Mar 2010 20:13 Do you mean something like this (windows, windows embedded etc.)? InitiateSystemShutdownEx(NULL, NULL, 0, TRUE, TRUE, SHTDN_REASON_MAJOR_HARDWARE) For details see the windows SDK. (In windows)you first need to setup permissions: Taken from an example watchdog service: LUID localUid; HANDLE hToken; TOKEN_PRIVILEGES tokenPrivileges; . . . . . if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES, &hToken)) MessageBox(NULL, "OpenProcessToken Error", "Setup Error", MB_OK | MB_SERVICE_NOTIFICATION); if (!LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &localUid)) MessageBox(NULL, "VIBMON: LookupPrivilegeValue Error", "Setup Error", MB_OK | MB_SERVICE_NOTIFICATION); tokenPrivileges.PrivilegeCount = 1; tokenPrivileges.Privileges[0].Luid = localUid; tokenPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; if (!AdjustTokenPrivileges(hToken, FALSE, &tokenPrivileges, sizeof(TOKEN_PRIVILEGES), (PTOKEN_PRIVILEGES) NULL, (PDWORD) NULL)) { msgString << "AdjustTokenPrivileges Error: " << hex << GetLastError() << ends; MessageBox(NULL, msgString.str(), "Setup Error", MB_OK | MB_SERVICE_NOTIFICATION); msgString.seekp(0, ios::beg); msgString.rdbuf()->freeze(0); } Jim Stewart schrieb: > I know that if you push the power button on a > running PC, the machine does not power down > until the OS has done its shutdown silly walk. > > Are there software hooks that allow an application > to shutdown in an orderly fashion first?
From: Chris Burrows on 17 Mar 2010 20:47 "Jim Stewart" <jstewart(a)jkmicro.com> wrote in message news:hnr9s0$adc$1(a)news.eternal-september.org... > > Are there software hooks that allow an application > to shutdown in an orderly fashion first? In Windows there is the WM_QUERYENDSESSION message: http://msdn.microsoft.com/en-us/library/aa376890(VS.85).aspx -- Chris Burrows CFB Software http://www.cfbsoftware.com
From: George Neuner on 18 Mar 2010 00:34 On Thu, 18 Mar 2010 10:09:05 +1000, Tom <tom(a)no.spam.invalid> wrote: > >Be aware that in Windows some applications may refuse [to shut down]and >OS will not shut down. We had to look for a workaround for UPS to shutdown >a PC with Citect Scada running on it. There is a registry setting that forces termination of hung processes instead of displaying a message and waiting until doomsday for a user response. There is also a "hung process" timeout value which controls when the auto kill kicks in. This is separate from the normal process shutdown timeout. See: http://www.addictivetips.com/windows-tips/how-to-speed-up-windows-shutdown-process/ George
From: Tom on 18 Mar 2010 01:47
George Neuner wrote: > On Thu, 18 Mar 2010 10:09:05 +1000, Tom <tom(a)no.spam.invalid> wrote: > >> Be aware that in Windows some applications may refuse [to shut down]and >> OS will not shut down. We had to look for a workaround for UPS to shutdown >> a PC with Citect Scada running on it. > > There is a registry setting that forces termination of hung processes > instead of displaying a message and waiting until doomsday for a user > response. > > There is also a "hung process" timeout value which controls when the > auto kill kicks in. This is separate from the normal process shutdown > timeout. > > See: > http://www.addictivetips.com/windows-tips/how-to-speed-up-windows-shutdown-process/ > > > George In my case Citect wasn't hung, it was designed not to shut down as this software often controls industrial systems etc. - it simply replies to Windows that it needs to run and shutdown doesn't happen, Windows happily continues to run. Citect can be stopped by authorized user and then you can shutdown the computer. We used it in less critical application and wanted a clean shutdown when no operator is around, power went off and UPS battery is about to give up. Tom |