[Mono-list] Question on unix signal handling

Ian Norton ian.norton-badrul at thales-esecurity.com
Thu Jan 17 16:02:12 UTC 2013

I'd be very careful with signals and mono, for one thing, the soft-debugger
uses signals to convey things like step in/out/next 

Remember, that signal handlers are supposed to never make function calls beyond
the standard library. If you signal handler is written in c# you've already
broken than particular idea.


On Thu, Jan 17, 2013 at 04:02:50PM +0000, mickeyf wrote:
> I'm new to signals. Looking over the Mono docs, and various articles on the
> web, it's clear that this has evolved as Mono matured. I just want to make
> sure I understand how it actually works today, and what I should expect. 
> I see   in this documentation:
> <http://oddacon.hopto.org:8181/1.1/handlers/monodoc.ashx?link=T%3AMono.Unix.UnixSignal>   
> "In a multi-threaded program, a thread is selected at random among the
> threads that can handle the signal, and that thread is hijacked to run the
> signal"
> I understand that that is referring to _unmanaged_ *nix code, not Mono.
> Further along in the same doc, we have 
> "[Mono.Unix.UnixSignal] uses an internal unmanaged signal handler."
> So, I'm thinking of using code based on height8's (only 2 year old) blog
> post :  here <http://www.height8.com/?unixsignal_mono>  
> So my questions are:
> If I have a Mono application with an arbitrary number of threads, can I use
> this approach to make sure that any signal is properly caught and handled by
> a single method? That is, will any signals that are raised be seen only by
> my signal handler, and ignored by everything else?
> If my Mono app is using unmanaged libraries, I presumably have to ensure
> that the library code also either ignores any signals or handles them in a
> sensible way. (Using signal(2), or SIGACTION(2) ?)
> What I'm ultimately aiming at is that I can 
> a) make sure that I can shut down my application cleanly and completely by
> sending it a signal (ctrl-C from the keyboard for example), and that 
> b) it does not get tripped up by signals that may originate from other
> processes other than a system shut down, an intentional "kill", etc.
> thanks
> --
> View this message in context: http://mono.1490590.n4.nabble.com/Question-on-unix-signal-handling-tp4658167.html
> Sent from the Mono - General mailing list archive at Nabble.com.
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list

More information about the Mono-list mailing list