[Mono-list] SIGKILL/SIGTERM handling

Paolo Molaro lupus@ximian.com
Fri, 14 Mar 2003 18:45:20 +0100


On 03/10/03 Jerome Laban wrote:
>     My goal here is to build something like a daemon, as for now, there is
> no support for services in mono. If I get this thing to work, I'll look
> closer at implementing this part. (There were some interesting posts here
> with this concern, just wondering if someone is working on it)
> 
>     As for the example, a signal handler is registered as well as a managed
> delegate method. The signal is handled fine, but the mono runtime seems to
> handle it too... and this not what I want.

The mono runtime doesn't install handlers for SIGTERM.

> I'm not totally fluent with signals, so I may be missing something or I may
> be running after something that is not possible with the mono runtime.

Note that inside signal handlers some things are not permitted and maybe
the SIGTERM triggered something that caused a SEGV or something else and
hence the mono handler kicked in. Registering a delegate as a callback
for a signal should not be considered safe.
A suggestion for what you may need that signal for (since you're going
to terminate the app anyway), is to siglongjmp out of the signal handler
and to call mono_runtime_invoke() in a safer context.

lupus

-- 
-----------------------------------------------------------------
lupus@debian.org                                     debian/rules
lupus@ximian.com                             Monkeys do it better