Mono.Posix
1.0.5000.0
2.0.0.0
4.0.0.0
All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.
System.Threading.WaitHandle
Represents the number of times a Unix signal has been emitted.
Unix signals are used (generally) for two things:
-
Asynchronous alerts about events that occur within a process, such as
illegal instruction (),
floating point exception (),
bus error (),
invalid memory access (),
I/O is possible (),
etc.
-
Asynchronous alerts of external "events", such as
termanal hangup (),
keyboard interrupt (),
broken pipe (),
program-defined actions
(,
),
child exit (),
etc.
The key nature about signals is that they are asynchronous. In a
single threaded program, when a signal occurs the executing thread is
"hijacked" (no matter what it was previously doing) in order to
execute a (optionally registered) signal handler, and then the thread
resumes what it was previously doing (if possible; the signal handler
may abort the process as part of its execution).
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 handler before continuing (while the other threads continue
to execute in ignorance that a signal is occuring).
Tradtionally, is used
to register a signal handler for a signal, and the registered handler
is invoked when the signal is generated. However, due to the
"hijacking" nature of the signal handling process, what the signal
handler could do is severely restricted: it must not invoke
non-reentrant library functions, and can only modify global data and
execute a limited set of system calls such as
and
.
Managed code throws an additional wrench in the works, as the platform
invocation mechanism is neither reentrant nor signal safe. Consequently,
managed code can not be safely and reliably used as a signal
handler (as would traditionally be done with signal(2)), thus
the type.
A instance represents the number
of times that a Unix signal has been emitted. That's all.
UnixSignal instances support:
-
Accessing the number of times the Unix signal has been emitted via
the
and properties.
-
Clearing the count with .
-
Sleeping until a signal has been emitted via
and
.
In order to operate, this class uses an internal unmanaged signal
handler to represent the count information. Consequently, the count
will only be updated as long as no other mechanism is used to change
the registered signal handler, such as
or
. If you use
or
for the same
signal as a created UnixSignal instance, the UnixSignal
instance will stop operating as documented. Don't Do That (TM).
There is currently a limit of 64 concurrent UnixSignal
instances within a process.
Constructor
2.0.0.0
4.0.0.0
A value specifying which
Unix realtime signal this instance should count.
Creates and initializes a
class instance.
This constructor initializes the
property of the new
instance using .
Once this constructor completes execution, all signal emissions
between the completion of the constructor and the invocation of
will be
counted, updating the
property.
Realtime signal registration has the constraint that it cannot override signals
registered from outside of Mono.Posix.
This constraint exists because the underlying aplication and runtime can use some
signals to implement some specific feature.
The internal signal handler could not be registered or the signal was registered outside of Mono.Posix.
is not a valid signal value.
Constructor
1.0.5000.0
2.0.0.0
4.0.0.0
A value specifying which
Unix signal this instance should count.
Creates and initializes a
class instance.
This constructor initializes the
property of the new
instance using .
Once this constructor completes execution, all signal emissions
between the completion of the constructor and the invocation of
will be
counted, updating the
property.
The internal signal handler could not be registered.
is not a valid signal value.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.Int32
The number of times the
signal has been emitted since construction or the last call to
.
A containing the number of the
of times the
signal has been emitted.
To clear the count, either assign 0 to the
property or use
.
The current instance has already been disposed.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Void
A ; if , then
this invocation is due to a
call;
if , this invocation is from within the
finalizer.
Cleanup all unmanaged resources.
This method releases all unmanaged resources held by the current
instance. When is
, this method releases all resources held
by any managed objects referenced by the current instance. This
method invokes the Dispose() method of each referenced
object.
Override this mthod to dispose of resources allocated by types
derived from . When
overriding
,
be careful not to reference objects that have been previously
disposed an earlier call to Dispose or Close.
Dispose can be called multiple times by other objects.
This method is called by the protected
method and the method.
Dispose() invokes this method with the
parameter set to
.
invokes
Dispose with set to
.
Property
2.0.0.0
4.0.0.0
System.Boolean
Returns if the registered signal is realtime.
A specifying whether or not the registered
signal is realtime.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
System.Boolean
Returns if
is greater than 0.
A specifying whether or not
is greater than 0.
The current instance has already been disposed.
Property
2.0.0.0
4.0.0.0
Mono.Unix.Native.RealTimeSignum
The RealTime Unix signal this instance is counting
A value specifying which
RealTime Unix signal this instance is counting.
This value is set in the
constructor.
The current instance is registered for a non-realtime signal.
The current instance has already been disposed.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Boolean
Clears the property; the
return value specifies whether or not
was not equal to 0
before it was cleared.
A specifying whether or not the
property was not equal
to 0 before it was cleared. If is returned,
was not 0; if
is returned,
was 0.
This method atomically checks and clears the
property, and should
be preferred over manually checking and clearing the
property.
The current instance has already been disposed.
Property
1.0.5000.0
2.0.0.0
4.0.0.0
Mono.Unix.Native.Signum
The Unix signal this instance is counting.
A value specifying which
Unix signal this instance is counting.
This value is set in the
constructor.
The current instance is registered for a realtime signal.
The current instance has already been disposed.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Int32
A array containing the
instances to wait on.
Blocks the current thread until one of the
instances within
has a non-zero
.
Returns a set to the index of the
element in that received a signal.
This method is equivalent to calling
UnixSignal.WaitAny(, -1).
is .
One of the instances within
was disposed.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Int32
A array containing the
instances to wait on.
A specifying the number of
milliseconds to wait before the method should return. -1
represents an infinite timeout.
Blocks the current thread until one of the
instances within
has a non-zero
or the timeout expires.
If the method doesn't timeout, returns a
set to the index of the
element in that received a signal.
If the method does timeout, then
is returned.
is .
is less than -1.
One of the instances within
was disposed.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Int32
A array containing the
instances to wait on.
A specifying how long the method
should wait before returning. Use a
with a value of
-1 for an infinite timeout.
Blocks the current thread until one of the
instances within
has a non-zero
or the timeout expires.
If the method doesn't timeout, returns a
set to the index of the
element in that received a signal.
If the method does timeout, then 's
value cast to a
is returned.
This is equivalent to
UnixSignal.WaitAny(,
timeout.TotalMilliseconds).
is .
's
property is less
than -1 or greater than .
One of the instances within
was disposed.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Boolean
Blocks the current thread until the curent instance has a non-zero
.
Returns when the current instance receives a
signal.
The caller of this method blocks indefinitely until the
signal is received by
the current process and the
property is non-zero.
This method is equivalent to calling WaitOne(-1).
The current instance has already been disposed.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Boolean
A containing the maximum number of
milliseconds the current thread should block before returning.
This parameter must be .
Blocks the current thread until the curent instance has a non-zero
or the timeout expires.
Returns when the current instance receives a
signal, otherwise is returned if the
timeout is exceeded.
The caller of this method blocks for up to
for the
signal to be received
by the current process and the
property to become
non-zero.
is less than -1.
is .
The current instance has already been disposed.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Boolean
A specifying how long the method
should wait before returning. Use a
with a value of
-1 for an infinite timeout.
This parameter must be .
Blocks the current thread until the curent instance has a non-zero
or the timeout expires.
Returns when the current instance receives a
signal, otherwise is returned if the
timeout is exceeded.
The caller of this method blocks for up to
timeout.TotalMilliseconds milliseconds for the
signal to be received
by the current process and the
property to become
non-zero.
's
property is less
than -1 or greater than .
is .
The current instance has already been disposed.