system.signal.set

local set = system.signal.set.new(system.signal.SIGTERM, system.signal.SIGINT)
set:wait()

This class provides the ability to wait for one or more signals to occur.

Multiple registration of signals

The same signal number may be registered with different [set] objects. When the signal occurs, one [signal notification is queued] for each [set] object.

Functions

new([sig1: integer, …​]) → system.signal.set

Constructor.

Arguments are treated as signals to be added to the set.

Only the main VM on the process may create new set objects. If the VM elects another VM to be the new main VM, its old set objects will remain valid and working, but the VM won’t be able to create new set objects.

add(self, signal: integer)

Add a signal to the set.

Only the master VM is allowed to use this function.

remove(self, signal: integer)

Remove a signal from the set.

clear(self)

Remove all signals from the set.

cancel(self)

Cancel all operations associated with the set.

wait(self) → integer

Wait for a signal to be delivered. The function will return when:

  • One of the registered signals in the set occurs; or

  • The set was cancelled, in which case the function will raise the exception boost::asio::error::operation_aborted.

A number is returned to indicate which signal occurred.

Queueing of signal notifications

If a signal is registered with a [set], and the signal occurs when there are no [calls to wait()], then the signal notification is queued. The next [call to wait() on that set] will dequeue the notification. If multiple notifications are queued, subsequent [wait() calls] dequeue them one at a time. Signal notifications are dequeued in order of ascending signal number.

If a signal number is removed from a [set] (using the [remove() member function]) then any queued notifications for that signal are discarded.