[Mono-list] Question on unix signal handling
mickeyf
mickey at thesweetoasis.com
Mon Jan 21 20:32:10 UTC 2013
I'm finding that if I run height8's example code exactly as is, as an
independent application, it works as expected.
If I use that identical code to watch a UnixSignal and to shut down my
application, there is no indication that SIGTERM, SIGINT or SIGQUIT are
being caught. The big difference is probably that I do have multiple threads
running (in the managed code only). I have made sure that there is no
reference to signal handling in the unmanaged libraries or anywhere else in
the C# code.
Ctrl-C (with no special handling at all) does seem to halt console output,
which implies that this is being caught at some low level. However, after a
Ctrl-C, "ps aux | grep myapp" shows that I still have myapp.exe and
/usr/bin/cli myapp.exe running, and one of the devices I'm talking to shows
that it's still connected. In any case, UnixSignal.WaitAny doesn't seem to
be behaving as I hoped.
I'm guessing that some other thread must be getting the signals. The fact
that Ctrl-C is not ignored supports this.
I can shut the 2 listed processes down with a script that looks for that
name and sends a kill, but that by itself does not clean up everything as it
ought.
Interestingly, a Console.CancelKeyPress handler does catch Ctrl-C and allows
me to call a shut down routine that shuts down all my running processes,
releases resources, etc.
So on the one hand I do have a way to cleanly shut down this app, and my
immediate problem is solved. On the other hand, I'm still missing something
about how to effectively use UnixSignal in mono.
--
View this message in context: http://mono.1490590.n4.nabble.com/Question-on-unix-signal-handling-tp4658167p4658215.html
Sent from the Mono - General mailing list archive at Nabble.com.
More information about the Mono-list
mailing list