On Sat, Jan 9, 2010 at 18:53, David T. Lewis <[email protected]> wrote:
> On Fri, Jan 08, 2010 at 05:51:51PM +0100, Damien Pollet wrote:
>> Hi,
>>
>> Chaff is a tiny class to intercept the SIGTERM signal and save the
>> image http://www.squeaksource.com/Chaff.html
>>
>> Several problems:
>>
>> - OSProcess accessor forwardSigTern will only work once. Once the VM
>> has registered a handler for a given signal, it can't clean it up or
>> register another semaphore, until the image restarts.
>
> Not so. The plugin allows you to reset a signal handler to its default
> value for exactly this reason. This is the method comment in
> UnixOSProcessPlugin (the part that runs in the VM):
>
> forwardSignal: sigNum toSemaphoreAt: semaphoreIndex
>        "Set a signal handler in the VM which will signal a Smalltalk 
> semaphore at
>        semaphoreIndex whenever an external signal sigNum is received. Answer 
> the
>        prior value of the signal handler. If semaphoreIndex is zero, the 
> handler is
>        unregistered, and the VM returns to its default behavior for handling 
> that
>        signal. A handler must be unregistered before it can be registered 
> again.
>
>        The Smalltalk semaphore is expected to be kept at the same index 
> location
>        indefinitely during the lifetime of a Squeak session. If that is not 
> the case, the
>        handler must be unregistered prior to unregistering the Smalltalk 
> semaphore."
>
> Thus in UnixOSProcessAccessor you have #forwardSigInt to set a handler,
> and #restoreSigInt to restore the signal handler to its default. After
> it has been restored you can set it again.
>
>> - If I have a process waiting on the semaphore, but the image quits
>> for a different reason, I guess when it restarts, the process will
>> still be there but the semaphore will be invalid??? what's a good way to
>> handle that ?
>
> The semaphore will be valid but will receive no signals from the VM.
> When you restart the image, you will need to set your signal handlers
> at that time. Most likely you will want to just start a new process,
> perhaps in a #startUp: method.

Thanks !


-- 
Damien Pollet
type less, do more [ | ] http://people.untyped.org/damien.pollet

_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to