Event system
The following syscalls are used in the event system, including events that can be sent to other processes.
kill(pid: number, signal: number)
Sends a signal to another process.
Parameters
pid
: The ID of the process to send tosignal
: The signal ID to send
Return Values
This syscall does not return anything.
Errors
This syscall may throw an error if:
- The target process ID does not exist.
- The current user does not have permission to send a signal to the target.
- The target process must be under the same user as the current one.
- If the current process is running as root, it may send a signal to any process.
signal(signal: number, handler: function(signal: number))
Registers a handler function to be called for a signal.
Parameters
signal
: The signal ID to register for.handler
: The handler function to call, which takes the signal ID as its only argument.
Return Values
This syscall does not return anything.
Errors
This syscall does not throw errors.
queueEvent(name: string, params: table)
Queues an arbitrary event to be sent back to the current process.
Parameters
name
: The name of the event to send.params
: The parameter list to send in the event.
Return Values
This syscall does not return anything.
Errors
This syscall does not throw errors.
sendEvent(pid: number, name: string, params: any)
Queues a remote event to be sent to another process.
Parameters
pid
: The ID of the process to send to.name
: The name of the remote event to send.params
: The data to send with the event.
Return Values
This syscall does not return anything.
Errors
This syscall does not throw errors.
timer(timeout: number): number
Sets a timer that will send a timer
event after the specified number of seconds.
Parameters
timeout
: The amount of time to set the timer for.
Return Values
The ID of the new timer created.
Errors
This syscall does not throw errors.
alarm(timeout: number): number
Sets an alarm that will send an alarm
event at the specified time.
Parameters
timeout
: The time to set the alarm to.
Return Values
The ID of the new alarm created.
Errors
This syscall does not throw errors.
cancel(tm: number)
Cancels a previously set timer or alarm.
Parameters
tm
: The ID of the timer or alarm to cancel.
Return Values
This syscall does not return anything.
Errors
This syscall does not throw errors.