[vwnc] Is it posible to handle killing the visual process?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[vwnc] Is it posible to handle killing the visual process?

Emiliano Pérez-3
Hi list, i´m running a headless image as an Opentalk server for my application (running in windows XP). To avoid lossing data, i catch the event of shuting down the image to make a backup. I got my subsystem (as a UserApplication subclass) and works fine unless the process is killed via windows task manager.
Is there any way to do something before the S.O. kills the process via subsystems or other mechanism?

Thanks, Emiliano.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Is it posible to handle killing the visual process?

Wallen, David
I think VW does handle the global "windows is shutting down" (WM_SHUTDOWN?) message. You could presumably change the handler for that so that your data gets saved. It might turn out that the local "windows is shutting down your application" message differs only in a passed parameter. I dunno offhand, but others on the list can surely comment about this.

- Dave W

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf
> Of Emiliano Pérez
> Sent: Thursday, September 18, 2008 7:41 AM
> To: vwnc-list
> Subject: [vwnc] Is it posible to handle killing the visual process?
>
> Hi list, i´m running a headless image as an Opentalk server for my
> application (running in windows XP). To avoid lossing data, i catch the
> event of shuting down the image to make a backup. I got my subsystem (as a
> UserApplication subclass) and works fine unless the process is killed via
> windows task manager.
> Is there any way to do something before the S.O. kills the process via
> subsystems or other mechanism?
>
> Thanks, Emiliano.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

[vwnc] Is it posible to handle killing the visual process?

Emiliano Pérez-3
Thanks for the hint David!

Any idea on actually how does VW handle the shutdown message? Or where can i add some behavior to it?
I been playing a little with the S.O. events catched from vw but i couldn´t see any "shutdown" or "close" event, only the normal quit (closing the image properly) event that ends up doing "ObjectMemory quit" and stoping all the systems.

Now my quest gets a little more tecnical. For debugging´s sake i´ve hacked the "InputState>>process: event" so that it would write each received event in an external file transcript and commits the external stream so every received event will be logged until i kill the visual.exe (or vwnt.exe) process.
The weird thing is that between the last normal event in the image (let´s suppouse the last mouse move) and force killing the process via windows task manager no new event was received. Could it be that these events (WM_SHUTDOWN, WM_CLOSE) are managed via virtual machine and don´t get to be managed by my code? Or maybe the transcript has not enough time to be writen before the image is killed?

Any help on this will be much apreciated. Regards, Emiliano.


2008/9/18 Wallen, David <[hidden email]>

I think VW does handle the global "windows is shutting down" (WM_SHUTDOWN?) message. You could presumably change the handler for that so that your data gets saved. It might turn out that the local "windows is shutting down your application" message differs only in a passed parameter. I dunno offhand, but others on the list can surely comment about this.

- Dave W

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf
> Of Emiliano Pérez
> Sent: Thursday, September 18, 2008 7:41 AM
> To: vwnc-list
> Subject: [vwnc] Is it posible to handle killing the visual process?
>
> Hi list, i´m running a headless image as an Opentalk server for my
> application (running in windows XP). To avoid lossing data, i catch the
> event of shuting down the image to make a backup. I got my subsystem (as a
> UserApplication subclass) and works fine unless the process is killed via
> windows task manager.
> Is there any way to do something before the S.O. kills the process via
> subsystems or other mechanism?
>
> Thanks, Emiliano.



_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Is it posible to handle killing the visual process?

Wallen, David

Check out “Exiting VisualWorks” -> “Closing Windows” in Chapter 1 of the AppDevGuide.pdf. I haven’t worked with that system, but it may help you a bit.

 

- Dave

 


From: [hidden email] [mailto:[hidden email]] On Behalf Of Emiliano Pérez
Sent: Monday, September 29, 2008 11:57 AM
To: [hidden email]
Subject: [vwnc] Is it posible to handle killing the visual process?

 

Thanks for the hint David!


Any idea on actually how does VW handle the shutdown message? Or where can i add some behavior to it?
I been playing a little with the S.O. events catched from vw but i couldn´t see any "shutdown" or "close" event, only the normal quit (closing the image properly) event that ends up doing "ObjectMemory quit" and stoping all the systems.

Now my quest gets a little more tecnical. For debugging´s sake i´ve hacked the "InputState>>process: event" so that it would write each received event in an external file transcript and commits the external stream so every received event will be logged until i kill the visual.exe (or vwnt.exe) process.
The weird thing is that between the last normal event in the image (let´s suppouse the last mouse move) and force killing the process via windows task manager no new event was received. Could it be that these events (WM_SHUTDOWN, WM_CLOSE) are managed via virtual machine and don´t get to be managed by my code? Or maybe the transcript has not enough time to be writen before the image is killed?

Any help on this will be much apreciated. Regards, Emiliano.

2008/9/18 Wallen, David <[hidden email]>

 

I think VW does handle the global "windows is shutting down" (WM_SHUTDOWN?) message. You could presumably change the handler for that so that your data gets saved. It might turn out that the local "windows is shutting down your application" message differs only in a passed parameter. I dunno offhand, but others on the list can surely comment about this.

- Dave W


> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf
> Of Emiliano Pérez
> Sent: Thursday, September 18, 2008 7:41 AM
> To: vwnc-list
> Subject: [vwnc] Is it posible to handle killing the visual process?
>
> Hi list, i´m running a headless image as an Opentalk server for my
> application (running in windows XP). To avoid lossing data, i catch the
> event of shuting down the image to make a backup. I got my subsystem (as a
> UserApplication subclass) and works fine unless the process is killed via
> windows task manager.
> Is there any way to do something before the S.O. kills the process via
> subsystems or other mechanism?
>
> Thanks, Emiliano.

 

 


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Is it posible to handle killing the visual process?

Reinout Heeck
In reply to this post by Emiliano Pérez-3
Emiliano Pérez wrote:

>
> Any help on this will be much apreciated.

Not very helpful, but this conversation reminds me of "crash-only software":
   http://en.wikipedia.org/wiki/Crash-only_software



R
-
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Is it posible to handle killing the visual process?

Emiliano Pérez-3
In reply to this post by Wallen, David
David, i´ve checked the AppDevGuide and tried the suggestions, but they didn´t work for me. 
I´ve managed to stop the image from closing upon power off evaluating the following code (taken from the InputState>>run method):

ObjectMemory registerObject: false withEngineFor: 'acceptQuitEvents'

This leaves the pc unable to shutdown while the image is open (you can always close the image and then shutdown). What i couldn't do is picking up the event of actually pressing the power off button (the #send:eventQuitSystem: message is not send). If i could do this i´ll be able to save all the data and then closing the image and the pc directly from my code.

Back on the technical side, i´ve identified two events that apparently are sent only when you press the power button. I´ve done this excluding all the others that are sent in normal situations (mouse, keyboard and window events in general) by a "homemade" trial and error technique. I log the events id with this code in the InputState>>proccess: event method:

((event at: 10) longAt: 9) printString

I´ve got this interpretation of events from the "Windows ColorDepth Workaraund" and what it gets when i press the power button are the events 59 and 22 which are 3B and 16 in hexadecimal base. I´ve come to think that this events are only sent when you press the power button but i coudn´t find any documentation to confirm this in the windows library or any other place (yes, i´ve googled a lot) so i can´t really be sure that they are not received in other context (which would result in wrongly shutting down the pc).
 
Anyway at this point I don´t know if anyone can help me but i though i share this with everyone. 

Thanks a lot, Emiliano.


2008/9/29 Wallen, David <[hidden email]>

Check out "Exiting VisualWorks" -> "Closing Windows" in Chapter 1 of the AppDevGuide.pdf. I haven't worked with that system, but it may help you a bit.

 

- Dave

 


From: [hidden email] [mailto:[hidden email]] On Behalf Of Emiliano Pérez
Sent: Monday, September 29, 2008 11:57 AM
To: [hidden email]


Subject: [vwnc] Is it posible to handle killing the visual process?

 

Thanks for the hint David!


Any idea on actually how does VW handle the shutdown message? Or where can i add some behavior to it?
I been playing a little with the S.O. events catched from vw but i couldn´t see any "shutdown" or "close" event, only the normal quit (closing the image properly) event that ends up doing "ObjectMemory quit" and stoping all the systems.

Now my quest gets a little more tecnical. For debugging´s sake i´ve hacked the "InputState>>process: event" so that it would write each received event in an external file transcript and commits the external stream so every received event will be logged until i kill the visual.exe (or vwnt.exe) process.
The weird thing is that between the last normal event in the image (let´s suppouse the last mouse move) and force killing the process via windows task manager no new event was received. Could it be that these events (WM_SHUTDOWN, WM_CLOSE) are managed via virtual machine and don´t get to be managed by my code? Or maybe the transcript has not enough time to be writen before the image is killed?

Any help on this will be much apreciated. Regards, Emiliano.

2008/9/18 Wallen, David <[hidden email]>

 

I think VW does handle the global "windows is shutting down" (WM_SHUTDOWN?) message. You could presumably change the handler for that so that your data gets saved. It might turn out that the local "windows is shutting down your application" message differs only in a passed parameter. I dunno offhand, but others on the list can surely comment about this.

- Dave W


> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf
> Of Emiliano Pérez
> Sent: Thursday, September 18, 2008 7:41 AM
> To: vwnc-list
> Subject: [vwnc] Is it posible to handle killing the visual process?
>
> Hi list, i´m running a headless image as an Opentalk server for my
> application (running in windows XP). To avoid lossing data, i catch the
> event of shuting down the image to make a backup. I got my subsystem (as a
> UserApplication subclass) and works fine unless the process is killed via
> windows task manager.
> Is there any way to do something before the S.O. kills the process via
> subsystems or other mechanism?
>
> Thanks, Emiliano.

 

 



_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Is it posible to handle killing the visual process?

Steven Kelly
In reply to this post by Emiliano Pérez-3

When the user tries to shutdown, restart or log off, Windows sends the WM_QUERYENDSESSION  (16r11 = 17) message to all applications. The VM responds true or false to WM_QUERYENDSESSION depending on the value of acceptQuitEvents. Note that the VM responds: the image doesn’t get a chance to intervene. From Windows’ point of view, if all applications return true then the shutdown proceeds; if any return false (zero), the shutdown is not started and Windows stops asking any remaining applications. However, the applications that replied true will still be closed with WM_ENDSESSION (apparently: the Windows docs seem to contradict each other on this).

 

Regardless of the result of WM_QUERYENDSESSION, Windows sends WM_ENDSESSION (16r16 = 22) to all windows, passing the overall result as a Boolean in wParam. If you want a VW window to receive WM_ENDSESSION, add the following in its postOpenWith: method:

                aBuilder window application: self.

                aBuilder window sendWindowEvents: #(#eventUnknown)

 

In its windowEvent:from: method you can then add:

               (anEvent key == #eventUnknown and: [Screen default platformName = 'MS-Windows' and: [((anEvent value at: 10) longAt: 9) = 22]])

                                ifTrue: [self closeRequest]

 

The ifTrue: action can of course be whatever you want. The test is probably not quite right, because we should also check that wParam is true – remember WM_ENDSESSION is sent even if some app refused WM_QUERYENDSESSION and hence Windows will not actually shut down. Here are the contents of “anEvent value” in that case:

#(0 2469 0 0 0 0 0 0 0 #[0 0 0 0 165 9 0 0   22 0 0 0    0 0 0 0   0 0 0 0] 0 nil nil nil nil nil)

I guess longAt: 13 will be wParam and longAt: 17 will be lParam (I’m assuming 32-bit Windows here: in 64-bit, I think HWND is 64 bits, not sure about the others). So maybe an extra check:

 

((anEvent value at: 10) longAt: 13) ~= 0

 

before deciding to do whatever pre-shutdown tidying up your app requires.

 

I don’t know what your hex 3B is: it’s not listed anywhere that I could find.

 

The details are here:

http://msdn.microsoft.com/en-us/library/aa376890(VS.85).aspx

 

Finally, note this all applies to normal GUI apps. If you have a console app or a service, shutdown notification is different. For services, see WinService in the public repository: call it with something like this:

 

[              interface := WinServiceInterface new.

                interface

                                startDispatcherWithHandler:

                                                [:event |

                                                (event = interface SERVICE_CONTROL_STOP

                                                or: [event = interface SERVICE_CONTROL_SHUTDOWN])

                                                                ifTrue:

                                                                                [“ADD YOUR SERVICE SHUTDOWN CODE HERE”]]

                                serviceName: serviceName

                                startupBlock:

                                                [“ADD YOUR SERVICE STARTUP CODE HERE”]

] fork

 

HTH,

Steve

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Emiliano Pérez
Sent: 03 October 2008 16:43
To: [hidden email]
Subject: Re: [vwnc] Is it posible to handle killing the visual process?

 

David, i´ve checked the AppDevGuide and tried the suggestions, but they didn´t work for me. 
I´ve managed to stop the image from closing upon power off evaluating the following code (taken from the InputState>>run method):

ObjectMemory registerObject: false withEngineFor: 'acceptQuitEvents'

This leaves the pc unable to shutdown while the image is open (you can always close the image and then shutdown). What i couldn't do is picking up the event of actually pressing the power off button (the #send:eventQuitSystem: message is not send). If i could do this i´ll be able to save all the data and then closing the image and the pc directly from my code.

Back on the technical side, i´ve identified two events that apparently are sent only when you press the power button. I´ve done this excluding all the others that are sent in normal situations (mouse, keyboard and window events in general) by a "homemade" trial and error technique. I log the events id with this code in the InputState>>proccess: event method:

((event at: 10) longAt: 9) printString

I´ve got this interpretation of events from the "Windows ColorDepth Workaraund" and what it gets when i press the power button are the events 59 and 22 which are 3B and 16 in hexadecimal base. I´ve come to think that this events are only sent when you press the power button but i coudn´t find any documentation to confirm this in the windows library or any other place (yes, i´ve googled a lot) so i can´t really be sure that they are not received in other context (which would result in wrongly shutting down the pc).
 
Anyway at this point I don´t know if anyone can help me but i though i share this with everyone. 

Thanks a lot, Emiliano.

2008/9/29 Wallen, David <[hidden email]>

Check out "Exiting VisualWorks" -> "Closing Windows" in Chapter 1 of the AppDevGuide.pdf. I haven't worked with that system, but it may help you a bit.

 

- Dave

 


From: [hidden email] [mailto:[hidden email]] On Behalf Of Emiliano Pérez
Sent: Monday, September 29, 2008 11:57 AM
To: [hidden email]


Subject: [vwnc] Is it posible to handle killing the visual process?

 

Thanks for the hint David!


Any idea on actually how does VW handle the shutdown message? Or where can i add some behavior to it?
I been playing a little with the S.O. events catched from vw but i couldn´t see any "shutdown" or "close" event, only the normal quit (closing the image properly) event that ends up doing "ObjectMemory quit" and stoping all the systems.

Now my quest gets a little more tecnical. For debugging´s sake i´ve hacked the "InputState>>process: event" so that it would write each received event in an external file transcript and commits the external stream so every received event will be logged until i kill the visual.exe (or vwnt.exe) process.
The weird thing is that between the last normal event in the image (let´s suppouse the last mouse move) and force killing the process via windows task manager no new event was received. Could it be that these events (WM_SHUTDOWN, WM_CLOSE) are managed via virtual machine and don´t get to be managed by my code? Or maybe the transcript has not enough time to be writen before the image is killed?

Any help on this will be much apreciated. Regards, Emiliano.

2008/9/18 Wallen, David <[hidden email]>

 

I think VW does handle the global "windows is shutting down" (WM_SHUTDOWN?) message. You could presumably change the handler for that so that your data gets saved. It might turn out that the local "windows is shutting down your application" message differs only in a passed parameter. I dunno offhand, but others on the list can surely comment about this.

- Dave W


> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf
> Of Emiliano Pérez
> Sent: Thursday, September 18, 2008 7:41 AM
> To: vwnc-list
> Subject: [vwnc] Is it posible to handle killing the visual process?
>
> Hi list, i´m running a headless image as an Opentalk server for my
> application (running in windows XP). To avoid lossing data, i catch the
> event of shuting down the image to make a backup. I got my subsystem (as a
> UserApplication subclass) and works fine unless the process is killed via
> windows task manager.
> Is there any way to do something before the S.O. kills the process via
> subsystems or other mechanism?
>
> Thanks, Emiliano.

 

 

 


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Is it posible to handle killing the visual process?

Wallen, David

Steve,

 

This goes much further than our docs in Chapter 1! I’ll file this info away for future reference.

Hopefully Emiliano can find what he needs here.

 

- Dave

 


From: [hidden email] [mailto:[hidden email]] On Behalf Of Steven Kelly
Sent: Friday, October 03, 2008 2:56 PM
To: [hidden email]
Subject: Re: [vwnc] Is it posible to handle killing the visual process?

 

When the user tries to shutdown, restart or log off, Windows sends the WM_QUERYENDSESSION  (16r11 = 17) message to all applications. The VM responds true or false to WM_QUERYENDSESSION depending on the value of acceptQuitEvents. Note that the VM responds: the image doesn’t get a chance to intervene. From Windows’ point of view, if all applications return true then the shutdown proceeds; if any return false (zero), the shutdown is not started and Windows stops asking any remaining applications. However, the applications that replied true will still be closed with WM_ENDSESSION (apparently: the Windows docs seem to contradict each other on this).

 

Regardless of the result of WM_QUERYENDSESSION, Windows sends WM_ENDSESSION (16r16 = 22) to all windows, passing the overall result as a Boolean in wParam. If you want a VW window to receive WM_ENDSESSION, add the following in its postOpenWith: method:

                aBuilder window application: self.

                aBuilder window sendWindowEvents: #(#eventUnknown)

 

In its windowEvent:from: method you can then add:

               (anEvent key == #eventUnknown and: [Screen default platformName = 'MS-Windows' and: [((anEvent value at: 10) longAt: 9) = 22]])

                                ifTrue: [self closeRequest]

 

The ifTrue: action can of course be whatever you want. The test is probably not quite right, because we should also check that wParam is true – remember WM_ENDSESSION is sent even if some app refused WM_QUERYENDSESSION and hence Windows will not actually shut down. Here are the contents of “anEvent value” in that case:

#(0 2469 0 0 0 0 0 0 0 #[0 0 0 0 165 9 0 0   22 0 0 0    0 0 0 0   0 0 0 0] 0 nil nil nil nil nil)

I guess longAt: 13 will be wParam and longAt: 17 will be lParam (I’m assuming 32-bit Windows here: in 64-bit, I think HWND is 64 bits, not sure about the others). So maybe an extra check:

 

((anEvent value at: 10) longAt: 13) ~= 0

 

before deciding to do whatever pre-shutdown tidying up your app requires.

 

I don’t know what your hex 3B is: it’s not listed anywhere that I could find.

 

The details are here:

http://msdn.microsoft.com/en-us/library/aa376890(VS.85).aspx

 

Finally, note this all applies to normal GUI apps. If you have a console app or a service, shutdown notification is different. For services, see WinService in the public repository: call it with something like this:

 

[              interface := WinServiceInterface new.

                interface

                                startDispatcherWithHandler:

                                                [:event |

                                                (event = interface SERVICE_CONTROL_STOP

                                                or: [event = interface SERVICE_CONTROL_SHUTDOWN])

                                                                ifTrue:

                                                                                [“ADD YOUR SERVICE SHUTDOWN CODE HERE”]]

                                serviceName: serviceName

                                startupBlock:

                                                [“ADD YOUR SERVICE STARTUP CODE HERE”]

] fork

 

HTH,

Steve

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Emiliano Pérez
Sent: 03 October 2008 16:43
To: [hidden email]
Subject: Re: [vwnc] Is it posible to handle killing the visual process?

 

David, i´ve checked the AppDevGuide and tried the suggestions, but they didn´t work for me. 
I´ve managed to stop the image from closing upon power off evaluating the following code (taken from the InputState>>run method):

ObjectMemory registerObject: false withEngineFor: 'acceptQuitEvents'

This leaves the pc unable to shutdown while the image is open (you can always close the image and then shutdown). What i couldn't do is picking up the event of actually pressing the power off button (the #send:eventQuitSystem: message is not send). If i could do this i´ll be able to save all the data and then closing the image and the pc directly from my code.

Back on the technical side, i´ve identified two events that apparently are sent only when you press the power button. I´ve done this excluding all the others that are sent in normal situations (mouse, keyboard and window events in general) by a "homemade" trial and error technique. I log the events id with this code in the InputState>>proccess: event method:

((event at: 10) longAt: 9) printString

I´ve got this interpretation of events from the "Windows ColorDepth Workaraund" and what it gets when i press the power button are the events 59 and 22 which are 3B and 16 in hexadecimal base. I´ve come to think that this events are only sent when you press the power button but i coudn´t find any documentation to confirm this in the windows library or any other place (yes, i´ve googled a lot) so i can´t really be sure that they are not received in other context (which would result in wrongly shutting down the pc).
 
Anyway at this point I don´t know if anyone can help me but i though i share this with everyone. 

Thanks a lot, Emiliano.

2008/9/29 Wallen, David <[hidden email]>

Check out "Exiting VisualWorks" -> "Closing Windows" in Chapter 1 of the AppDevGuide.pdf. I haven't worked with that system, but it may help you a bit.

 

- Dave

 


From: [hidden email] [mailto:[hidden email]] On Behalf Of Emiliano Pérez
Sent: Monday, September 29, 2008 11:57 AM
To: [hidden email]


Subject: [vwnc] Is it posible to handle killing the visual process?

 

Thanks for the hint David!


Any idea on actually how does VW handle the shutdown message? Or where can i add some behavior to it?
I been playing a little with the S.O. events catched from vw but i couldn´t see any "shutdown" or "close" event, only the normal quit (closing the image properly) event that ends up doing "ObjectMemory quit" and stoping all the systems.

Now my quest gets a little more tecnical. For debugging´s sake i´ve hacked the "InputState>>process: event" so that it would write each received event in an external file transcript and commits the external stream so every received event will be logged until i kill the visual.exe (or vwnt.exe) process.
The weird thing is that between the last normal event in the image (let´s suppouse the last mouse move) and force killing the process via windows task manager no new event was received. Could it be that these events (WM_SHUTDOWN, WM_CLOSE) are managed via virtual machine and don´t get to be managed by my code? Or maybe the transcript has not enough time to be writen before the image is killed?

Any help on this will be much apreciated. Regards, Emiliano.

2008/9/18 Wallen, David <[hidden email]>

 

I think VW does handle the global "windows is shutting down" (WM_SHUTDOWN?) message. You could presumably change the handler for that so that your data gets saved. It might turn out that the local "windows is shutting down your application" message differs only in a passed parameter. I dunno offhand, but others on the list can surely comment about this.

- Dave W


> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf
> Of Emiliano Pérez
> Sent: Thursday, September 18, 2008 7:41 AM
> To: vwnc-list
> Subject: [vwnc] Is it posible to handle killing the visual process?
>
> Hi list, i´m running a headless image as an Opentalk server for my
> application (running in windows XP). To avoid lossing data, i catch the
> event of shuting down the image to make a backup. I got my subsystem (as a
> UserApplication subclass) and works fine unless the process is killed via
> windows task manager.
> Is there any way to do something before the S.O. kills the process via
> subsystems or other mechanism?
>
> Thanks, Emiliano.

 

 

 


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Is it posible to handle killing the visual process?

Emiliano Pérez-3
Steven, that was really really helpful.
When i read that all this was managed via VM i kind of lost my faith, but the WinServiceInterface looks like could work for me, it definitely fits my case because this was in fact a service with no GUI. I will get to it right away.
Also the method from my previous mail seems to fail for non-gui apps because those described events are i fact not received.
Regarding the 3B event, i found a few answers but none of them seemed remotely related with the O.S. shutting down. I guess it will remain a mystery, at least until someone close to the windows api can shed some light into it.

Let´s  hope that this will also keep others from banging their heads into the wall with this issue.

Thanks a lot to both of you, Emiliano.

2008/10/3 Wallen, David <[hidden email]>

Steve,

 

This goes much further than our docs in Chapter 1! I'll file this info away for future reference.

Hopefully Emiliano can find what he needs here.

 

- Dave

 


From: [hidden email] [mailto:[hidden email]] On Behalf Of Steven Kelly
Sent: Friday, October 03, 2008 2:56 PM


To: [hidden email]
Subject: Re: [vwnc] Is it posible to handle killing the visual process?

 

When the user tries to shutdown, restart or log off, Windows sends the WM_QUERYENDSESSION  (16r11 = 17) message to all applications. The VM responds true or false to WM_QUERYENDSESSION depending on the value of acceptQuitEvents. Note that the VM responds: the image doesn't get a chance to intervene. From Windows' point of view, if all applications return true then the shutdown proceeds; if any return false (zero), the shutdown is not started and Windows stops asking any remaining applications. However, the applications that replied true will still be closed with WM_ENDSESSION (apparently: the Windows docs seem to contradict each other on this).

 

Regardless of the result of WM_QUERYENDSESSION, Windows sends WM_ENDSESSION (16r16 = 22) to all windows, passing the overall result as a Boolean in wParam. If you want a VW window to receive WM_ENDSESSION, add the following in its postOpenWith: method:

                aBuilder window application: self.

                aBuilder window sendWindowEvents: #(#eventUnknown)

 

In its windowEvent:from: method you can then add:

               (anEvent key == #eventUnknown and: [Screen default platformName = 'MS-Windows' and: [((anEvent value at: 10) longAt: 9) = 22]])

                                ifTrue: [self closeRequest]

 

The ifTrue: action can of course be whatever you want. The test is probably not quite right, because we should also check that wParam is true – remember WM_ENDSESSION is sent even if some app refused WM_QUERYENDSESSION and hence Windows will not actually shut down. Here are the contents of "anEvent value" in that case:

#(0 2469 0 0 0 0 0 0 0 #[0 0 0 0 165 9 0 0   22 0 0 0    0 0 0 0   0 0 0 0] 0 nil nil nil nil nil)

I guess longAt: 13 will be wParam and longAt: 17 will be lParam (I'm assuming 32-bit Windows here: in 64-bit, I think HWND is 64 bits, not sure about the others). So maybe an extra check:

 

((anEvent value at: 10) longAt: 13) ~= 0

 

before deciding to do whatever pre-shutdown tidying up your app requires.

 

I don't know what your hex 3B is: it's not listed anywhere that I could find.

 

The details are here:

http://msdn.microsoft.com/en-us/library/aa376890(VS.85).aspx

 

Finally, note this all applies to normal GUI apps. If you have a console app or a service, shutdown notification is different. For services, see WinService in the public repository: call it with something like this:

 

[              interface := WinServiceInterface new.

                interface

                                startDispatcherWithHandler:

                                                [:event |

                                                (event = interface SERVICE_CONTROL_STOP

                                                or: [event = interface SERVICE_CONTROL_SHUTDOWN])

                                                                ifTrue:

                                                                                ["ADD YOUR SERVICE SHUTDOWN CODE HERE"]]

                                serviceName: serviceName

                                startupBlock:

                                                ["ADD YOUR SERVICE STARTUP CODE HERE"]

] fork

 

HTH,

Steve

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Emiliano Pérez
Sent: 03 October 2008 16:43
To: [hidden email]
Subject: Re: [vwnc] Is it posible to handle killing the visual process?

 

David, i´ve checked the AppDevGuide and tried the suggestions, but they didn´t work for me. 
I´ve managed to stop the image from closing upon power off evaluating the following code (taken from the InputState>>run method):

ObjectMemory registerObject: false withEngineFor: 'acceptQuitEvents'

This leaves the pc unable to shutdown while the image is open (you can always close the image and then shutdown). What i couldn't do is picking up the event of actually pressing the power off button (the #send:eventQuitSystem: message is not send). If i could do this i´ll be able to save all the data and then closing the image and the pc directly from my code.

Back on the technical side, i´ve identified two events that apparently are sent only when you press the power button. I´ve done this excluding all the others that are sent in normal situations (mouse, keyboard and window events in general) by a "homemade" trial and error technique. I log the events id with this code in the InputState>>proccess: event method:

((event at: 10) longAt: 9) printString

I´ve got this interpretation of events from the "Windows ColorDepth Workaraund" and what it gets when i press the power button are the events 59 and 22 which are 3B and 16 in hexadecimal base. I´ve come to think that this events are only sent when you press the power button but i coudn´t find any documentation to confirm this in the windows library or any other place (yes, i´ve googled a lot) so i can´t really be sure that they are not received in other context (which would result in wrongly shutting down the pc).
 
Anyway at this point I don´t know if anyone can help me but i though i share this with everyone. 

Thanks a lot, Emiliano.

2008/9/29 Wallen, David <[hidden email]>

Check out "Exiting VisualWorks" -> "Closing Windows" in Chapter 1 of the AppDevGuide.pdf. I haven't worked with that system, but it may help you a bit.

 

- Dave

 


From: [hidden email] [mailto:[hidden email]] On Behalf Of Emiliano Pérez
Sent: Monday, September 29, 2008 11:57 AM
To: [hidden email]


Subject: [vwnc] Is it posible to handle killing the visual process?

 

Thanks for the hint David!


Any idea on actually how does VW handle the shutdown message? Or where can i add some behavior to it?
I been playing a little with the S.O. events catched from vw but i couldn´t see any "shutdown" or "close" event, only the normal quit (closing the image properly) event that ends up doing "ObjectMemory quit" and stoping all the systems.

Now my quest gets a little more tecnical. For debugging´s sake i´ve hacked the "InputState>>process: event" so that it would write each received event in an external file transcript and commits the external stream so every received event will be logged until i kill the visual.exe (or vwnt.exe) process.
The weird thing is that between the last normal event in the image (let´s suppouse the last mouse move) and force killing the process via windows task manager no new event was received. Could it be that these events (WM_SHUTDOWN, WM_CLOSE) are managed via virtual machine and don´t get to be managed by my code? Or maybe the transcript has not enough time to be writen before the image is killed?

Any help on this will be much apreciated. Regards, Emiliano.

2008/9/18 Wallen, David <[hidden email]>

 

I think VW does handle the global "windows is shutting down" (WM_SHUTDOWN?) message. You could presumably change the handler for that so that your data gets saved. It might turn out that the local "windows is shutting down your application" message differs only in a passed parameter. I dunno offhand, but others on the list can surely comment about this.

- Dave W


> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf
> Of Emiliano Pérez
> Sent: Thursday, September 18, 2008 7:41 AM
> To: vwnc-list
> Subject: [vwnc] Is it posible to handle killing the visual process?
>
> Hi list, i´m running a headless image as an Opentalk server for my
> application (running in windows XP). To avoid lossing data, i catch the
> event of shuting down the image to make a backup. I got my subsystem (as a
> UserApplication subclass) and works fine unless the process is killed via
> windows task manager.
> Is there any way to do something before the S.O. kills the process via
> subsystems or other mechanism?
>
> Thanks, Emiliano.

 

 

 


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc



_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc