private int signum;
private IntPtr signal_info;
+ static UnixSignal ()
+ {
+ Stdlib.VersionCheck ();
+ }
+
public UnixSignal (Signum signum)
{
this.signum = NativeConvert.FromSignum (signum);
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
delegate int Mono_Posix_RuntimeIsShuttingDown ();
+ static Mono_Posix_RuntimeIsShuttingDown ShuttingDown = RuntimeShuttingDownCallback;
+
+ static int RuntimeShuttingDownCallback ()
+ {
+ return Environment.HasShutdownStarted ? 1 : 0;
+ }
[DllImport (Stdlib.MPH, CallingConvention=CallingConvention.Cdecl,
EntryPoint="Mono_Unix_UnixSignal_WaitAny")]
set {Interlocked.Exchange (ref Info->count, value);}
}
+ // signum, count, write_fd, pipecnt, and pipelock are read from a signal handler thread
+ // count and pipelock are both read and written from the signal handler thread
[Map]
struct SignalInfo {
- public int signum, count, read_fd, write_fd, have_handler, pipecnt;
- public IntPtr handler;
+ public int signum, count, read_fd, write_fd, pipecnt, pipelock, have_handler;
+ public IntPtr handler; // Backed-up handler to restore when signal unregistered
}
#region WaitHandle overrides
return WaitAny (signals, (int) ms);
}
+
public static unsafe int WaitAny (UnixSignal[] signals, int millisecondsTimeout)
{
if (signals == null)
if (infos [i] == IntPtr.Zero)
throw new InvalidOperationException ("Disposed UnixSignal");
}
- Mono_Posix_RuntimeIsShuttingDown shutting_down = () =>
- Environment.HasShutdownStarted ? 1 : 0;
- int r = WaitAny (infos, infos.Length, millisecondsTimeout, shutting_down);
- GC.KeepAlive (shutting_down);
- return r;
+ return WaitAny (infos, infos.Length, millisecondsTimeout, ShuttingDown);
}
}
}