private int signum;
private IntPtr signal_info;
+ static UnixSignal ()
+ {
+ Stdlib.VersionCheck ();
+ }
+
public UnixSignal (Signum signum)
{
this.signum = NativeConvert.FromSignum (signum);
EntryPoint="Mono_Unix_UnixSignal_uninstall")]
private static extern int uninstall (IntPtr info);
+ [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")]
- private static extern int WaitAny (IntPtr[] infos, int count, int timeout);
+ private static extern int WaitAny (IntPtr[] infos, int count, int timeout, Mono_Posix_RuntimeIsShuttingDown shutting_down);
[DllImport (Stdlib.MPH, CallingConvention=CallingConvention.Cdecl,
EntryPoint="Mono_Posix_SIGRTMIN")]
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;
- 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");
}
- return WaitAny (infos, infos.Length, millisecondsTimeout);
+ return WaitAny (infos, infos.Length, millisecondsTimeout, ShuttingDown);
}
}
}