[Mono-dev] Control-C handler
pablosantosluac at terra.es
Thu Dec 20 20:06:15 EST 2007
Ok, I think I got a bit lost here... how should I proceed then?
----- Original Message -----
From: "Jonathan Pryor" <jonpryor at vt.edu>
To: "Miguel de Icaza" <miguel at novell.com>
Cc: <mono-devel-list at lists.ximian.com>
Sent: Thursday, December 20, 2007 8:41 PM
Subject: Re: [Mono-dev] Control-C handler
> On Thu, 2007-12-20 at 14:16 -0500, Miguel de Icaza wrote:
>> > You can use signal(2), which is helpfully exposed by Mono.Posix.dll.
>> > See the attached program.
>> This actually would corrupt the application state, because the C-c
>> handler will run the entire JIT at that point and this happens in the
>> same thread as the executing thread.
> Isn't there a method that says "JIT this function now"? (I thought
> Marshal.Prelink() did that, which is what Stdlib.signal() calls, but I
> just re-read the documentation and it doesn't do anything of the sort.)
> Before dropping to C, though, there are two alternatives:
> 1. Call handler() *before* passing it to Stdlib.signal():
> handler (-1);
> Stdlib.signal (Signum.SIGINT, handler);
> /* ... as before ... */
> This would require changing handler() to know about this initialization
> call and NOT set ctrl_c_pressed if the parameter is -1.
> This would also allow a pure C# signal handler, as the method will be
> JITed during the first handler() call.
> 2. Use System.Runtime.ConstrainedExecution.PrePrepareMethodAttribute on
> the signal handler method. This would require that Mono have support
> for Constrained Execution regions, which I believe is currently lacking,
> but would presumably eventually be supported.
> - Jon
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
More information about the Mono-devel-list