1. Silent Crash
- Posted by "Pete Stoner" <pete.stoner at BTConnect.com> Nov 06, 2003
- 544 views
Hi All, I see this has been discussed in the past, but I'm looking for any way around it.. I am writing a (win32) program that will be running on an unattended PC locked in a machine room, my program is interfacing with an external commercial program. If it has a problem it cannot handle it closes itself down and after a time a monitor program (which checks if it is running) restarts it and (courtesy of Thomas Parslows 'Interprocess Communications') presses the 'Start' button so my program can retry.. If (as happens sometimes) the commercial program is hanging and needs a windose reboot then my program forces that (using Wizmo) and with the monitor program in the Start folder everything tries again.. My potential problem is if my program crashes - since there seems to be no way of getting a 'Silent' crash without the console msg as far as windose (and my monitor program) is concerned the failed program is still running (although 'not responding'). If this happens then unless someone actually checks the PC (either physically or remotely using TightVNC) we will not know it isn't running. I wonder if there is some way I can check for this (my monitor prog could then send me email or force a reboot to recover). The ideal solutions would be a Crash_routine, but this is not available (and has been discussed to death in the past), or even just an option to turn off the console msg and allow the program to close completely. The only way I can see at present would be to use Matts Modified Interpreter which seems to have this crash_routine option, but I really wanted to give them an exe file and it appears I cannot bind using this.. Any ideas? Pete.
2. Re: Silent Crash
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Nov 06, 2003
- 493 views
On Thu, 6 Nov 2003 14:57:59 -0000, Pete Stoner <pete.stoner at BTConnect.com> wrote: > My potential problem is if my program crashes - since there seems to be >no way of getting a 'Silent' crash without the console msg as far as windose >(and my monitor program) is concerned the failed program is still running >(although 'not responding'). Hi Pete The following should kill the debug window pretty sharpish (which could be a bit annoying if you leave this running and try to do any development . You can probably merge this with your monitor program, rather than having to start/leave three programs running. Regards, Pete include win32lib.ew constant Main = create(Window,"",0,0,0,0,0,0) constant KEYEVENTF_KEYUP = #02 atom user32, xkeybd_event, initKB initKB=0 procedure keybd(integer character) -- simulate a key press (and release!). -- character may be literal or a virtual key (eg VK_HOME) if not initKB then user32=open_dll("user32.dll") xkeybd_event = define_c_proc(user32, "keybd_event",{C_LONG,C_LONG,C_LONG,C_LONG}) initKB=1 end if c_proc(xkeybd_event,{character,0,0,0}) c_proc(xkeybd_event,{character,0,KEYEVENTF_KEYUP,0}) end procedure include window.ew -- Thomas Parslow's window finding functions procedure MainActTimerClose(integer self, integer event, sequence params) object hWnd if self or length(params) then end if -- suppress warnings if event=w32HActivate then setVisible(Main,False) setTimer(Main,1,40) -- 25 times a second (less may be better?) elsif event=w32HTimer then hWnd=window_GetCurrentWindow() if equal(window_GetCaption(hWnd),"EXW") then -- debug window_PostCloseMessage(hWnd) keybd('Y') end if elsif event=w32HClose then killTimer(Main,1) end if end procedure setHandler(Main,{w32HActivate,w32HClose,w32HTimer},routine_id("MainActTimerClose")) WinMain( Main, Normal )
3. Re: Silent Crash
- Posted by Pete_Stoner at BTConnect.com Nov 07, 2003
- 532 views
Thanks Pete, I made some minor modifications as I found I couldn't rely on the debug window coming to the foreground..(and the timer was a bit faster than I needed!) But it works great now.. Hopefully(!?) this 'crash' routine will not be needed but I like to cover all eventualities!! I may also add a time check so if the crash happens again too soon I'll force a reboot.. procedure onTimer_PMHCheck( integer self, integer event, sequence params) atom ret object hWnd, Caption if self or length(params) then end if -- suppress warnings if event = w32HActivate then setTimer( Monitor_Win, Monitor_Timer, 10000 ) elsif event = w32HTimer then if not ipc_IsProcessRunning("CallGenerator") then UpdateLog( "Call Generator program has Closed down... restarted by automatic monitor") shellExecute("open", "Call Generator.exe", SW_SHOWNORMAL) sleep(5) ipc_CallProc("CallGenerator","StartGenerator",{}) -- press start button elsif window_Exists("*\\Call Generator.exe") then window_PostCloseMessage(window_GetHwnd("*\\Call Generator.exe")) keybd('Y') UpdateLog("Call Generator program has crashed... closed down by automatic monitor") end if elsif event=w32HClose then killTimer(Monitor_Timer,1) end if end procedure setHandler(Monitor_Win,{w32HActivate, w32HClose, w32HTimer},routine_id("onTimer_PMHCheck"))