[7.8] Exiting a headless image on MacOS X

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

[7.8] Exiting a headless image on MacOS X

Randy Coulman
I have an image with a little Seaside app in it that I run headless on my iMac.  So far, I have not found a clean way to get this image to shut down.  It blocks an OS shutdown.  Right-clicking on the dock icon for the image and choosing Quit does nothing.  The only thing I've found that will work is to do a kill -9 from the command line (normal kill has no effect).

Is there a good. clean way to shut down a headless image on MacOS X?

Thanks,
Randy
--
Randy Coulman
[hidden email]

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

Re: [7.8] Exiting a headless image on MacOS X

jarober
Why not add an admin interface that executes ObjectMemory quit ?


On Oct 28, 2011, at 12:14 PM, Randy Coulman wrote:

I have an image with a little Seaside app in it that I run headless on my iMac.  So far, I have not found a clean way to get this image to shut down.  It blocks an OS shutdown.  Right-clicking on the dock icon for the image and choosing Quit does nothing.  The only thing I've found that will work is to do a kill -9 from the command line (normal kill has no effect).

Is there a good. clean way to shut down a headless image on MacOS X?

Thanks,
Randy
--
Randy Coulman
[hidden email]
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: [7.8] Exiting a headless image on MacOS X

cdavidshaffer
In reply to this post by Randy Coulman
On 10/28/11 12:14, Randy Coulman wrote:
> I have an image with a little Seaside app in it that I run headless on
> my iMac.  So far, I have not found a clean way to get this image to
> shut down.  It blocks an OS shutdown.  Right-clicking on the dock icon
> for the image and choosing Quit does nothing.  The only thing I've
> found that will work is to do a kill -9 from the command line (normal
> kill has no effect).
>
> Is there a good. clean way to shut down a headless image on MacOS X?
>
>
Normally I have a subsystem that, on startup, invokes a method like the
one below.  This isn't OSX-specific, works on Linux too.

installSignalHandler
    "Catch SIGTERM and exit"
   
    | sema |
    ObjectMemory registerObject: false withEngineFor: 'acceptQuitEvents'.
    sema := Semaphore new.
    ObjectMemory registerObject: sema withEngineFor: 'SIGTERM'.
    [[sema wait.     "Wait for signal to occur"
    Transcript cr; show: 'Received SIGTERM...exiting'; cr.
    ObjectMemory quit ] repeat] fork


HTH,

David


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

Re: [7.8] Exiting a headless image on MacOS X

Randy Coulman
Thanks for this, David.  It definitely helps, but not completely.  With a handler like this defined, I can use kill (without -9) to terminate the image, and it also terminates cleanly when I run the image as a LaunchAgent.  This is a definite improvement.

The only thing I couldn't get working quite right is to be able to right-click on the dock icon and select Quit - that one is still non-responsive.  I tried handlers for SIGINT, SIGTERM, and SIGQUIT with no luck on that score.

Thanks again for your help on this.  

Oh, and James, I had thought of adding a button to my web app (or an admin interface) to do this, but that was going to be a last resort kind of thing.  But thanks for the suggestion.

Randy

On Fri, Oct 28, 2011 at 9:56 AM, C. David Shaffer <[hidden email]> wrote:
On 10/28/11 12:14, Randy Coulman wrote:
> I have an image with a little Seaside app in it that I run headless on
> my iMac.  So far, I have not found a clean way to get this image to
> shut down.  It blocks an OS shutdown.  Right-clicking on the dock icon
> for the image and choosing Quit does nothing.  The only thing I've
> found that will work is to do a kill -9 from the command line (normal
> kill has no effect).
>
> Is there a good. clean way to shut down a headless image on MacOS X?
>
>
Normally I have a subsystem that, on startup, invokes a method like the
one below.  This isn't OSX-specific, works on Linux too.

installSignalHandler
    "Catch SIGTERM and exit"
   
    | sema |
    ObjectMemory registerObject: false withEngineFor: 'acceptQuitEvents'.
    sema := Semaphore new.
    ObjectMemory registerObject: sema withEngineFor: 'SIGTERM'.
    [[sema wait.     "Wait for signal to occur"
    Transcript cr; show: 'Received SIGTERM...exiting'; cr.
    ObjectMemory quit ] repeat] fork


HTH,

David


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




--
Randy Coulman
[hidden email]

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

Re: [7.8] Exiting a headless image on MacOS X

Alan Knight-2
Responding to Windows quit events is discussed on page 1-8 in the AppDevGuide (in 7.8 - page numbers may vary in other releases).



[hidden email]
1 November, 2011 12:44 PM


Thanks for this, David.  It definitely helps, but not completely.  With a handler like this defined, I can use kill (without -9) to terminate the image, and it also terminates cleanly when I run the image as a LaunchAgent.  This is a definite improvement.

The only thing I couldn't get working quite right is to be able to right-click on the dock icon and select Quit - that one is still non-responsive.  I tried handlers for SIGINT, SIGTERM, and SIGQUIT with no luck on that score.

Thanks again for your help on this.  

Oh, and James, I had thought of adding a button to my web app (or an admin interface) to do this, but that was going to be a last resort kind of thing.  But thanks for the suggestion.

Randy




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


[hidden email]
28 October, 2011 12:56 PM


On 10/28/11 12:14, Randy Coulman wrote:
Normally I have a subsystem that, on startup, invokes a method like the
one below. This isn't OSX-specific, works on Linux too.

installSignalHandler
"Catch SIGTERM and exit"

| sema |
ObjectMemory registerObject: false withEngineFor: 'acceptQuitEvents'.
sema := Semaphore new.
ObjectMemory registerObject: sema withEngineFor: 'SIGTERM'.
[[sema wait. "Wait for signal to occur"
Transcript cr; show: 'Received SIGTERM...exiting'; cr.
ObjectMemory quit ] repeat] fork


HTH,

David

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


[hidden email]
28 October, 2011 12:14 PM


I have an image with a little Seaside app in it that I run headless on my iMac.  So far, I have not found a clean way to get this image to shut down.  It blocks an OS shutdown.  Right-clicking on the dock icon for the image and choosing Quit does nothing.  The only thing I've found that will work is to do a kill -9 from the command line (normal kill has no effect).

Is there a good. clean way to shut down a headless image on MacOS X?

Thanks,
Randy
--
Randy Coulman
[hidden email]
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: [7.8] Exiting a headless image on MacOS X

Randy Coulman
That seems to only talk about Windows, and I'm talking about OS/X.  My original problem was that a headless image was (by default) ignoring any attempts to kill it, other than a kill -9 from the command line.

Randy

On Tue, Nov 1, 2011 at 10:11 AM, Alan Knight <[hidden email]> wrote:
Responding to Windows quit events is discussed on page 1-8 in the AppDevGuide (in 7.8 - page numbers may vary in other releases).



[hidden email]
1 November, 2011 12:44 PM


Thanks for this, David.  It definitely helps, but not completely.  With a handler like this defined, I can use kill (without -9) to terminate the image, and it also terminates cleanly when I run the image as a LaunchAgent.  This is a definite improvement.

The only thing I couldn't get working quite right is to be able to right-click on the dock icon and select Quit - that one is still non-responsive.  I tried handlers for SIGINT, SIGTERM, and SIGQUIT with no luck on that score.

Thanks again for your help on this.  

Oh, and James, I had thought of adding a button to my web app (or an admin interface) to do this, but that was going to be a last resort kind of thing.  But thanks for the suggestion.

Randy




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


[hidden email]
28 October, 2011 12:56 PM


On 10/28/11 12:14, Randy Coulman wrote:
Normally I have a subsystem that, on startup, invokes a method like the
one below. This isn't OSX-specific, works on Linux too.

installSignalHandler
"Catch SIGTERM and exit"

| sema |
ObjectMemory registerObject: false withEngineFor: 'acceptQuitEvents'.
sema := Semaphore new.
ObjectMemory registerObject: sema withEngineFor: 'SIGTERM'.
[[sema wait. "Wait for signal to occur"
Transcript cr; show: 'Received SIGTERM...exiting'; cr.
ObjectMemory quit ] repeat] fork


HTH,

David

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


[hidden email]
28 October, 2011 12:14 PM


I have an image with a little Seaside app in it that I run headless on my iMac.  So far, I have not found a clean way to get this image to shut down.  It blocks an OS shutdown.  Right-clicking on the dock icon for the image and choosing Quit does nothing.  The only thing I've found that will work is to do a kill -9 from the command line (normal kill has no effect).

Is there a good. clean way to shut down a headless image on MacOS X?

Thanks,
Randy
--
Randy Coulman
[hidden email]
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc



--
Randy Coulman
[hidden email]

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

Re: [7.8] Exiting a headless image on MacOS X

Alan Knight-2
Ah, missed that. It may be that quitting from the dock is doing something similar and that we ought to be treating that similarly to the way we treat the Windows quit events.



[hidden email]
1 November, 2011 1:18 PM


That seems to only talk about Windows, and I'm talking about OS/X.  My original problem was that a headless image was (by default) ignoring any attempts to kill it, other than a kill -9 from the command line.

Randy




--
Randy Coulman
[hidden email]


[hidden email]
1 November, 2011 1:11 PM


Responding to Windows quit events is discussed on page 1-8 in the AppDevGuide (in 7.8 - page numbers may vary in other releases).

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


[hidden email]
1 November, 2011 12:44 PM


Thanks for this, David.  It definitely helps, but not completely.  With a handler like this defined, I can use kill (without -9) to terminate the image, and it also terminates cleanly when I run the image as a LaunchAgent.  This is a definite improvement.

The only thing I couldn't get working quite right is to be able to right-click on the dock icon and select Quit - that one is still non-responsive.  I tried handlers for SIGINT, SIGTERM, and SIGQUIT with no luck on that score.

Thanks again for your help on this.  

Oh, and James, I had thought of adding a button to my web app (or an admin interface) to do this, but that was going to be a last resort kind of thing.  But thanks for the suggestion.

Randy




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


[hidden email]
28 October, 2011 12:56 PM


On 10/28/11 12:14, Randy Coulman wrote:
Normally I have a subsystem that, on startup, invokes a method like the
one below. This isn't OSX-specific, works on Linux too.

installSignalHandler
"Catch SIGTERM and exit"

| sema |
ObjectMemory registerObject: false withEngineFor: 'acceptQuitEvents'.
sema := Semaphore new.
ObjectMemory registerObject: sema withEngineFor: 'SIGTERM'.
[[sema wait. "Wait for signal to occur"
Transcript cr; show: 'Received SIGTERM...exiting'; cr.
ObjectMemory quit ] repeat] fork


HTH,

David

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


[hidden email]
28 October, 2011 12:14 PM


I have an image with a little Seaside app in it that I run headless on my iMac.  So far, I have not found a clean way to get this image to shut down.  It blocks an OS shutdown.  Right-clicking on the dock icon for the image and choosing Quit does nothing.  The only thing I've found that will work is to do a kill -9 from the command line (normal kill has no effect).

Is there a good. clean way to shut down a headless image on MacOS X?

Thanks,
Randy
--
Randy Coulman
[hidden email]
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: [7.8] Exiting a headless image on MacOS X

Randy Coulman
Possibly.  I tried Googling to figure out what signal was being sent to an app from that Quit menu choice, but couldn't find it anywhere.

Randy

On Tue, Nov 1, 2011 at 10:22 AM, Alan Knight <[hidden email]> wrote:
Ah, missed that. It may be that quitting from the dock is doing something similar and that we ought to be treating that similarly to the way we treat the Windows quit events.



[hidden email]
1 November, 2011 1:18 PM


That seems to only talk about Windows, and I'm talking about OS/X.  My original problem was that a headless image was (by default) ignoring any attempts to kill it, other than a kill -9 from the command line.

Randy




--
Randy Coulman
[hidden email]


[hidden email]
1 November, 2011 1:11 PM


Responding to Windows quit events is discussed on page 1-8 in the AppDevGuide (in 7.8 - page numbers may vary in other releases).

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


[hidden email]
1 November, 2011 12:44 PM


Thanks for this, David.  It definitely helps, but not completely.  With a handler like this defined, I can use kill (without -9) to terminate the image, and it also terminates cleanly when I run the image as a LaunchAgent.  This is a definite improvement.

The only thing I couldn't get working quite right is to be able to right-click on the dock icon and select Quit - that one is still non-responsive.  I tried handlers for SIGINT, SIGTERM, and SIGQUIT with no luck on that score.

Thanks again for your help on this.  

Oh, and James, I had thought of adding a button to my web app (or an admin interface) to do this, but that was going to be a last resort kind of thing.  But thanks for the suggestion.

Randy




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


[hidden email]
28 October, 2011 12:56 PM


On 10/28/11 12:14, Randy Coulman wrote:
Normally I have a subsystem that, on startup, invokes a method like the
one below. This isn't OSX-specific, works on Linux too.

installSignalHandler
"Catch SIGTERM and exit"

| sema |
ObjectMemory registerObject: false withEngineFor: 'acceptQuitEvents'.
sema := Semaphore new.
ObjectMemory registerObject: sema withEngineFor: 'SIGTERM'.
[[sema wait. "Wait for signal to occur"
Transcript cr; show: 'Received SIGTERM...exiting'; cr.
ObjectMemory quit ] repeat] fork


HTH,

David

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


[hidden email]
28 October, 2011 12:14 PM


I have an image with a little Seaside app in it that I run headless on my iMac.  So far, I have not found a clean way to get this image to shut down.  It blocks an OS shutdown.  Right-clicking on the dock icon for the image and choosing Quit does nothing.  The only thing I've found that will work is to do a kill -9 from the command line (normal kill has no effect).

Is there a good. clean way to shut down a headless image on MacOS X?

Thanks,
Randy
--
Randy Coulman
[hidden email]
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc



--
Randy Coulman
[hidden email]

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

Re: [7.8] Exiting a headless image on MacOS X

Alan Knight-2
I'm not sure it's a signal, it may be something that comes in via the OS X event loop. I suspect that Force Quit is a signal, but the ignorable Quit isn't.



[hidden email]
1 November, 2011 1:23 PM


Possibly.  I tried Googling to figure out what signal was being sent to an app from that Quit menu choice, but couldn't find it anywhere.

Randy




--
Randy Coulman
[hidden email]


[hidden email]
1 November, 2011 1:22 PM


Ah, missed that. It may be that quitting from the dock is doing something similar and that we ought to be treating that similarly to the way we treat the Windows quit events.

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


[hidden email]
1 November, 2011 1:18 PM


That seems to only talk about Windows, and I'm talking about OS/X.  My original problem was that a headless image was (by default) ignoring any attempts to kill it, other than a kill -9 from the command line.

Randy




--
Randy Coulman
[hidden email]


[hidden email]
1 November, 2011 1:11 PM


Responding to Windows quit events is discussed on page 1-8 in the AppDevGuide (in 7.8 - page numbers may vary in other releases).

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


[hidden email]
1 November, 2011 12:44 PM


Thanks for this, David.  It definitely helps, but not completely.  With a handler like this defined, I can use kill (without -9) to terminate the image, and it also terminates cleanly when I run the image as a LaunchAgent.  This is a definite improvement.

The only thing I couldn't get working quite right is to be able to right-click on the dock icon and select Quit - that one is still non-responsive.  I tried handlers for SIGINT, SIGTERM, and SIGQUIT with no luck on that score.

Thanks again for your help on this.  

Oh, and James, I had thought of adding a button to my web app (or an admin interface) to do this, but that was going to be a last resort kind of thing.  But thanks for the suggestion.

Randy




--
Randy Coulman
[hidden email]
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: [7.8] Exiting a headless image on MacOS X

Ralf Propach
In reply to this post by Randy Coulman

Hi Randy,

maybe NSApplicationDelegate>>applicationShouldTerminate: could help you.
See:
<a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40008592-CH1-SW4">http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40008592-CH1-SW4

I am not sure how you can set this up from Smalltalk.

Ralf

Am 01.11.2011 18:23, schrieb Randy Coulman:

> Possibly.  I tried Googling to figure out what signal was being sent to
> an app from that Quit menu choice, but couldn't find it anywhere.
>
> Randy
>
> On Tue, Nov 1, 2011 at 10:22 AM, Alan Knight <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Ah, missed that. It may be that quitting from the dock is doing
>     something similar and that we ought to be treating that similarly to
>     the way we treat the Windows quit events.
>
>>     ------------------------------------------------------------------------
>>
>>     Randy Coulman <mailto:[hidden email]>
>>     1 November, 2011 1:18 PM
>>
>>
>>     That seems to only talk about Windows, and I'm talking about OS/X.
>>      My original problem was that a headless image was (by default)
>>     ignoring any attempts to kill it, other than a kill -9 from the
>>     command line.
>>
>>     Randy
>>
>>
>>
>>
>>     --
>>     Randy Coulman
>>     [hidden email] <mailto:[hidden email]>
>>     ------------------------------------------------------------------------
>>
>>     Alan Knight <mailto:[hidden email]>
>>     1 November, 2011 1:11 PM
>>
>>
>>     Responding to Windows quit events is discussed on page 1-8 in the
>>     AppDevGuide (in 7.8 - page numbers may vary in other releases).
>>
>>     _______________________________________________
>>     vwnc mailing list
>>     [hidden email] <mailto:[hidden email]>
>>     http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>>     ------------------------------------------------------------------------
>>
>>     Randy Coulman <mailto:[hidden email]>
>>     1 November, 2011 12:44 PM
>>
>>
>>     Thanks for this, David.  It definitely helps, but not completely.
>>      With a handler like this defined, I can use kill (without -9) to
>>     terminate the image, and it also terminates cleanly when I run the
>>     image as a LaunchAgent.  This is a definite improvement.
>>
>>     The only thing I couldn't get working quite right is to be able to
>>     right-click on the dock icon and select Quit - that one is still
>>     non-responsive.  I tried handlers for SIGINT, SIGTERM, and SIGQUIT
>>     with no luck on that score.
>>
>>     Thanks again for your help on this.
>>
>>     Oh, and James, I had thought of adding a button to my web app (or
>>     an admin interface) to do this, but that was going to be a last
>>     resort kind of thing.  But thanks for the suggestion.
>>
>>     Randy
>>
>>
>>
>>
>>     --
>>     Randy Coulman
>>     [hidden email] <mailto:[hidden email]>
>>     _______________________________________________
>>     vwnc mailing list
>>     [hidden email] <mailto:[hidden email]>
>>     http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>>     ------------------------------------------------------------------------
>>
>>     C. David Shaffer <mailto:[hidden email]>
>>     28 October, 2011 12:56 PM
>>
>>
>>     On 10/28/11 12:14, Randy Coulman wrote:
>>     Normally I have a subsystem that, on startup, invokes a method
>>     like the
>>     one below. This isn't OSX-specific, works on Linux too.
>>
>>     installSignalHandler
>>     "Catch SIGTERM and exit"
>>
>>     | sema |
>>     ObjectMemory registerObject: false withEngineFor: 'acceptQuitEvents'.
>>     sema := Semaphore new.
>>     ObjectMemory registerObject: sema withEngineFor: 'SIGTERM'.
>>     [[sema wait. "Wait for signal to occur"
>>     Transcript cr; show: 'Received SIGTERM...exiting'; cr.
>>     ObjectMemory quit ] repeat] fork
>>
>>
>>     HTH,
>>
>>     David
>>
>>     _______________________________________________
>>     vwnc mailing list
>>     [hidden email] <mailto:[hidden email]>
>>     http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>>     ------------------------------------------------------------------------
>>
>>     Randy Coulman <mailto:[hidden email]>
>>     28 October, 2011 12:14 PM
>>
>>
>>     I have an image with a little Seaside app in it that I run
>>     headless on my iMac.  So far, I have not found a clean way to get
>>     this image to shut down.  It blocks an OS shutdown.
>>      Right-clicking on the dock icon for the image and choosing Quit
>>     does nothing.  The only thing I've found that will work is to do a
>>     kill -9 from the command line (normal kill has no effect).
>>
>>     Is there a good. clean way to shut down a headless image on MacOS X?
>>
>>     Thanks,
>>     Randy
>>     --
>>     Randy Coulman
>>     [hidden email] <mailto:[hidden email]>
>>     _______________________________________________
>>     vwnc mailing list
>>     [hidden email] <mailto:[hidden email]>
>>     http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>
>
>
>
> --
> Randy Coulman
> [hidden email] <mailto:[hidden email]>
>
>
>
> _______________________________________________
> 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
Reply | Threaded
Open this post in threaded view
|

Re: [7.8] Exiting a headless image on MacOS X

Karsten Kusche
Hi Randy,

the #applicationShouldTerminate: is already implemented in the VM, but it's passed to the application as a window-close event, which would probably work in Windows but in Mac OS X that's just incorrect. Closing all windows on a mac just means that all windows are closed, not at all does that mean that the application needs to quit. 

If you test the following in Mac OS X: open visual works and open a refactoring browser and hit cmd-q. What happens is that the window closes. The same happens, when you choose Quit from the ContextMenu, when right-clicking the Dock-Icon. Both events send a #terminate: to the NSApplication which ends up calling #applicationShouldTerminate:. VisualWorks should really handle that stuff properly. Closing the main window is just totally wrong. 

I just checked if you could register to NSApplicationWillTerminateNotification (could be done via CFNotificationCenter.. functions and DLLCC) but that notification is never called as the VM already canceled the termination before.

That all means that it's currently impossible to write an Application for Mac OS X that properly quits when asked by the OS. So you cannot log out from your Account, when VisualWorks is running, nor can you shut down your mac, when VisualWorks is running.


The only solution that you could try is implement a c-function in VisualWorks by registering a c-callback that takes a void* parameter and returns an integer. Then you need to use the Objective-C runtime API to call something along the lines of:

Method originalMethod = class_getInstanceMethod([[NSApplication sharedApplication] class], @selector(applicationShouldTerminate:));
method_setImplementation(originalMethod,cCallbackPointer);
 
to replace the implementation of the vm's applicationShouldTerminate: implementation.
In the callback you can return the proper value and your vm should already quit.


Kind Regards
Karsten





-- 
Karsten Kusche - Dipl. Inf. - [hidden email]
Georg Heeg eK - Köthen
Handelsregister: Amtsgericht Dortmund A 12812 

Am Mittwoch, 2. November 2011 um 16:32 schrieb Ralf Propach:



Hi Randy,

maybe NSApplicationDelegate>>applicationShouldTerminate: could help you.
See:
<a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40008592-CH1-SW4">http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40008592-CH1-SW4

I am not sure how you can set this up from Smalltalk.

Ralf

Am 01.11.2011 18:23, schrieb Randy Coulman:
Possibly. I tried Googling to figure out what signal was being sent to
an app from that Quit menu choice, but couldn't find it anywhere.

Randy

On Tue, Nov 1, 2011 at 10:22 AM, Alan Knight <[hidden email]
<[hidden email]>> wrote:

Ah, missed that. It may be that quitting from the dock is doing
something similar and that we ought to be treating that similarly to
the way we treat the Windows quit events.

------------------------------------------------------------------------

Randy Coulman <[hidden email]>
1 November, 2011 1:18 PM


That seems to only talk about Windows, and I'm talking about OS/X.
My original problem was that a headless image was (by default)
ignoring any attempts to kill it, other than a kill -9 from the
command line.

Randy




--
Randy Coulman
------------------------------------------------------------------------

Alan Knight <[hidden email]>
1 November, 2011 1:11 PM


Responding to Windows quit events is discussed on page 1-8 in the
AppDevGuide (in 7.8 - page numbers may vary in other releases).

_______________________________________________
vwnc mailing list
------------------------------------------------------------------------

Randy Coulman <[hidden email]>
1 November, 2011 12:44 PM


Thanks for this, David. It definitely helps, but not completely.
With a handler like this defined, I can use kill (without -9) to
terminate the image, and it also terminates cleanly when I run the
image as a LaunchAgent. This is a definite improvement.

The only thing I couldn't get working quite right is to be able to
right-click on the dock icon and select Quit - that one is still
non-responsive. I tried handlers for SIGINT, SIGTERM, and SIGQUIT
with no luck on that score.

Thanks again for your help on this.

Oh, and James, I had thought of adding a button to my web app (or
an admin interface) to do this, but that was going to be a last
resort kind of thing. But thanks for the suggestion.

Randy




--
Randy Coulman
_______________________________________________
vwnc mailing list
------------------------------------------------------------------------

C. David Shaffer <[hidden email]>
28 October, 2011 12:56 PM


On 10/28/11 12:14, Randy Coulman wrote:
Normally I have a subsystem that, on startup, invokes a method
like the
one below. This isn't OSX-specific, works on Linux too.

installSignalHandler
"Catch SIGTERM and exit"

| sema |
ObjectMemory registerObject: false withEngineFor: 'acceptQuitEvents'.
sema := Semaphore new.
ObjectMemory registerObject: sema withEngineFor: 'SIGTERM'.
[[sema wait. "Wait for signal to occur"
Transcript cr; show: 'Received SIGTERM...exiting'; cr.
ObjectMemory quit ] repeat] fork


HTH,

David

_______________________________________________
vwnc mailing list
------------------------------------------------------------------------

Randy Coulman <[hidden email]>
28 October, 2011 12:14 PM


I have an image with a little Seaside app in it that I run
headless on my iMac. So far, I have not found a clean way to get
this image to shut down. It blocks an OS shutdown.
Right-clicking on the dock icon for the image and choosing Quit
does nothing. The only thing I've found that will work is to do a
kill -9 from the command line (normal kill has no effect).

Is there a good. clean way to shut down a headless image on MacOS X?

Thanks,
Randy
--
Randy Coulman
_______________________________________________
vwnc mailing list




--
Randy Coulman



_______________________________________________
vwnc mailing list

_______________________________________________
vwnc mailing list


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

Re: [7.8] Exiting a headless image on MacOS X

Randy Coulman
Thanks for the ideas, guys.  This is just a little Seaside app for personal use, and with what I've done so far, I can make it do what I need it to for now.  Hopefully, this will get handled properly in the VM in a future version.

If I ever need something that does more than what I have, I'll try what Karsten is suggesting below.

Thanks again,
Randy

On Wed, Nov 2, 2011 at 9:30 AM, Karsten Kusche <[hidden email]> wrote:
Hi Randy,

the #applicationShouldTerminate: is already implemented in the VM, but it's passed to the application as a window-close event, which would probably work in Windows but in Mac OS X that's just incorrect. Closing all windows on a mac just means that all windows are closed, not at all does that mean that the application needs to quit. 

If you test the following in Mac OS X: open visual works and open a refactoring browser and hit cmd-q. What happens is that the window closes. The same happens, when you choose Quit from the ContextMenu, when right-clicking the Dock-Icon. Both events send a #terminate: to the NSApplication which ends up calling #applicationShouldTerminate:. VisualWorks should really handle that stuff properly. Closing the main window is just totally wrong. 

I just checked if you could register to NSApplicationWillTerminateNotification (could be done via CFNotificationCenter.. functions and DLLCC) but that notification is never called as the VM already canceled the termination before.

That all means that it's currently impossible to write an Application for Mac OS X that properly quits when asked by the OS. So you cannot log out from your Account, when VisualWorks is running, nor can you shut down your mac, when VisualWorks is running.


The only solution that you could try is implement a c-function in VisualWorks by registering a c-callback that takes a void* parameter and returns an integer. Then you need to use the Objective-C runtime API to call something along the lines of:

Method originalMethod = class_getInstanceMethod([[NSApplication sharedApplication] class], @selector(applicationShouldTerminate:));
method_setImplementation(originalMethod,cCallbackPointer);
 
to replace the implementation of the vm's applicationShouldTerminate: implementation.
In the callback you can return the proper value and your vm should already quit.


Kind Regards
Karsten





-- 
Karsten Kusche - Dipl. Inf. - [hidden email]
Georg Heeg eK - Köthen
Handelsregister: Amtsgericht Dortmund A 12812 

Am Mittwoch, 2. November 2011 um 16:32 schrieb Ralf Propach:



Hi Randy,

maybe NSApplicationDelegate>>applicationShouldTerminate: could help you.
See:

I am not sure how you can set this up from Smalltalk.

Ralf

Am 01.11.2011 18:23, schrieb Randy Coulman:
Possibly. I tried Googling to figure out what signal was being sent to
an app from that Quit menu choice, but couldn't find it anywhere.

Randy

On Tue, Nov 1, 2011 at 10:22 AM, Alan Knight <[hidden email]
<[hidden email]>> wrote:

Ah, missed that. It may be that quitting from the dock is doing
something similar and that we ought to be treating that similarly to
the way we treat the Windows quit events.

------------------------------------------------------------------------

Randy Coulman <[hidden email]>
1 November, 2011 1:18 PM


That seems to only talk about Windows, and I'm talking about OS/X.
My original problem was that a headless image was (by default)
ignoring any attempts to kill it, other than a kill -9 from the
command line.

Randy




--
Randy Coulman
------------------------------------------------------------------------

Alan Knight <[hidden email]>
1 November, 2011 1:11 PM


Responding to Windows quit events is discussed on page 1-8 in the
AppDevGuide (in 7.8 - page numbers may vary in other releases).

_______________________________________________
vwnc mailing list
------------------------------------------------------------------------

Randy Coulman <[hidden email]>
1 November, 2011 12:44 PM


Thanks for this, David. It definitely helps, but not completely.
With a handler like this defined, I can use kill (without -9) to
terminate the image, and it also terminates cleanly when I run the
image as a LaunchAgent. This is a definite improvement.

The only thing I couldn't get working quite right is to be able to
right-click on the dock icon and select Quit - that one is still
non-responsive. I tried handlers for SIGINT, SIGTERM, and SIGQUIT
with no luck on that score.

Thanks again for your help on this.

Oh, and James, I had thought of adding a button to my web app (or
an admin interface) to do this, but that was going to be a last
resort kind of thing. But thanks for the suggestion.

Randy




--
Randy Coulman
_______________________________________________
vwnc mailing list
------------------------------------------------------------------------

C. David Shaffer <[hidden email]>
28 October, 2011 12:56 PM


On 10/28/11 12:14, Randy Coulman wrote:
Normally I have a subsystem that, on startup, invokes a method
like the
one below. This isn't OSX-specific, works on Linux too.

installSignalHandler
"Catch SIGTERM and exit"

| sema |
ObjectMemory registerObject: false withEngineFor: 'acceptQuitEvents'.
sema := Semaphore new.
ObjectMemory registerObject: sema withEngineFor: 'SIGTERM'.
[[sema wait. "Wait for signal to occur"
Transcript cr; show: 'Received SIGTERM...exiting'; cr.
ObjectMemory quit ] repeat] fork


HTH,

David

_______________________________________________
vwnc mailing list
------------------------------------------------------------------------

Randy Coulman <[hidden email]>
28 October, 2011 12:14 PM


I have an image with a little Seaside app in it that I run
headless on my iMac. So far, I have not found a clean way to get
this image to shut down. It blocks an OS shutdown.
Right-clicking on the dock icon for the image and choosing Quit
does nothing. The only thing I've found that will work is to do a
kill -9 from the command line (normal kill has no effect).

Is there a good. clean way to shut down a headless image on MacOS X?

Thanks,
Randy
--
Randy Coulman
_______________________________________________
vwnc mailing list




--
Randy Coulman



_______________________________________________
vwnc mailing list

_______________________________________________
vwnc mailing list


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




--
Randy Coulman
[hidden email]

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