Module system.ipc¶
The IPC module provides functions for sending messages to other processes.
Index¶
Data
Constants for signal numbers |
Function
Sends a basic signal to a process. |
|
Returns the ID of the process that receives a service name. |
|
Waits for a remote event, filtering for processes or event names, with an optional timeout. |
|
Registers the current process as the receiver of a service name. |
|
Sends a remote event to a process. |
|
Sends an event to the owner of a service. |
|
Sets the handler for a signal. |
Class
Sockets are based on top of the remote event subsystem, sending messages through specially named events. |
API Reference¶
-
system.ipc.signal:
table¶ Constants for signal numbers
-
system.ipc.kill(pid:
number, signal:number):unknown¶ Sends a basic signal to a process.
- Parameters:
pid (
number) – The PID of the process to send tosignal (
number) – The signal to send to the process
-
system.ipc.sigaction(signal:
number, fn:function|nil):unknown¶ Sets the handler for a signal.
- Parameters:
signal (
number) – The signal to modifyfn (
function|nil) – The function to call, ornilto remove
-
system.ipc.sendEvent(pid:
number, event:string, param:table): (result:boolean)¶ Sends a remote event to a process.
- Parameters:
pid (
number) – The PID of the process to send toevent (
string) – The event name to sendparam (
table) – The parameter table to send with the event
- Returns:
result (
boolean) – Whether the event was sent
-
system.ipc.register(name:
string): (result:boolean)¶ Registers the current process as the receiver of a service name.
See :lua:obj:
lookup: To find a process for a service- Parameters:
name (
string) – The service name to register for- Returns:
result (
boolean) – Whether the service was registered
-
system.ipc.lookup(name:
string): (result:number|nil)¶ Returns the ID of the process that receives a service name.
See :lua:obj:
register: To register your process for a service- Parameters:
name (
string) – The service to lookup- Returns:
result (
number|nil) – The PID of the process that owns it (if available)
-
system.ipc.sendServiceEvent(name:
string, event:string, param:table): (result:boolean)¶ Sends an event to the owner of a service.
- Parameters:
name (
string) – The service to send toevent (
string) – The event name to sendparam (
table) – The parameter table to send with the event
- Returns:
result (
boolean) – Whether the event was sent
-
system.ipc.receiveEvent(pid?:
number, event?:string, timeout?:number): (event:string|nil, param:table|nil)¶ Waits for a remote event, filtering for processes or event names, with an optional timeout.
- Parameters:
pid? (
number) – The PID to wait for an event fromevent? (
string) – The event to filter fortimeout? (
number) – The maximum number of seconds to wait for
- Returns:
event (
string|nil) – The event name received, ornilif the timer timed outparam (
table|nil) – The parameters for the event
- class system.ipc.socket¶
Sockets are based on top of the remote event subsystem, sending messages through specially named events.
They implement the network handle interface and as such can be used instead of a network handle (though note that these sockets have no buffer and as such should not be used for continuous streams of data, as a network handle often is used for). Sockets will only receive messages from the same sender PID and socket name, so they can be isolated from other sockets.
-
status(self:
system.ipc.socket):string¶
-
close(self:
system.ipc.socket)¶
-
closed:
boolean¶
-
read(self:
system.ipc.socket, fmt:any, ...:unknown):string|number,string|number|nil,string|number|nil¶
-
write(self:
system.ipc.socket, obj:any, ...:unknown):unknown¶
-
status(self: